IDEA使用maven配置内置的Tomcat8

IDEA使用maven配置内置的Tomcat8,pom.xml文件的配置如下: 亲测有效,欢迎留言
第一步在build中加入如下配置: <plugins> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat8-maven-plugin</artifactId> <version>3.0-r1655215</version> <configuration> <!-- 通过maven tomcat8:run运行项目时,访问项目的端口号 --> <port>8080</port> <!--设置编码--> <uriEncoding>UTF-8</uriEncoding> <!-- 项目访问路径 本例:localhost:9090, 如果配置的aa, 则访问路径为localhost:9090/aa--> <path>/car-repair</path> </configuration> </plugin> <plugin> <!--配置jdk版本--> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins>
第二步:加入tomcat8插件:原因是由于maven中央仓库中没有tomcat8镜像,只有tomcat7 <!--配置Tomcat8仓库--> <pluginRepositories> <pluginRepository> <id>alfresco-public</id> <url>https://artifacts.alfresco.com/nexus/content/groups/public</url> </pluginRepository> <pluginRepository> <id>alfresco-public-snapshots</id> <url>https://artifacts.alfresco.com/nexus/content/groups/public-snapshots</url> <snapshots> <enabled>true</enabled> <updatePolicy>daily</updatePolicy> </snapshots> </pluginRepository> <!--这个google的用不了--> <!--<pluginRepository> <id>beardedgeeks-releases</id> <url>http://beardedgeeks.googlecode.com/svn/repository/releases</url> </pluginRepository>--> </pluginRepositories>
注意:加入以上配置后,如果下载比较慢,可以在maven目录下conf文件夹下的setting文件中配置: <mirror> <id>alimaven</id> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror> <mirror> <id>artifacts</id> <name>artifacts maven</name> <url>https://artifacts.alfresco.com/nexus/content/groups/public</url> <mirrorOf>*</mirrorOf> </mirror> </mirrors>

以上配置就完成了,然后就可以下载了,下载完成后,运行

启动服务器:创建maven,之后再用命令tomcat8:run-war,就可以启动成功了

 

经验分享 程序员 微信小程序 职场和发展