Maven 工程运行环境修改

maven 设置 jdk 编译版本

maven 插件设置 jdk 编译版本,在pom.xml中加入:

 <plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-compiler-plugin</artifactId>
     <configuration>
         <target>1.8</target>
         <source>1.8</source>
         <encoding>UTF-8</encoding>
     </configuration>
 </plugin>

maven 设置 tomcat 版本

maven 默认 tomcat 插件版本是6,可在pom文件中添加tomcat7插件,在pom.xml中加入:

<plugin>
     <groupId>org.apache.tomcat.maven</groupId>
     <artifactId>tomcat7-maven-plugin</artifactId>
     <version>2.2</version>
     <configuration>
         <port>9090</port>
         <uriEncoding>UTF-8</uriEncoding>
     </configuration>
 </plugin>

多了一个 tomcat7 插件:
Maven 工程运行环境修改
手动输入 tomcat7:run 命令运行项目:
Maven 工程运行环境修改
注意:
虽然手动加入了tomcat7插件,但是maven集成的tomcat6还是存在的,并不是覆盖了tomcat6,输入tomcat:run命令运行项目还是通过tomcat6部署的。
使用tomcat6部署jdk1.8编译的项目,会存在无法编译servlet问题。