插件:
-
编译器插件
pom.xml配置
<build> <plugins> <!-- java编译插件 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.2</version> <configuration> <source>1.8</source> <target>1.8</target> <encoding>UTF-8</encoding> </configuration> </plugin> </plugins> </build>
settings.xml文件中配置全局编译器插件
<profile> <!-- 定义的编译器插件ID,全局唯一 --> <id>jdk-1.8</id> <!-- 插件标记,activeByDefault 默认编译器,jdk提供编译器版本 --> <activation> <activeByDefault>true</activeByDefault> <jdk>1.8</jdk> </activation> <!-- 配置信息source-源信息,target-字节码信息,compilerVersion-编译过程版本 --> <properties> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion> </properties> </profile>
-
资源拷贝插件
Maven在打包时默认只将src/main/resources里的配置文件拷贝到项目中并做打包处理,而非resource目录下的配置文件在打包时不会添加到项目中
<build> <resources> <resource> <directory>src/main/java</directory> <includes> <--**/*代表java包下及其子包下--></--> <include>**/*.xml</include> </includes> </resource> <resource> <directory>src/main/resources</directory> <includes> <include>**/*.xml</include> <include>**/*.properties</include> </includes> </resource> </resources> </build>
-
Tomcat插件:
<build> <plugins> <!-- 配置Tomcat插件 --> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <configuration> <!-- 配置Tomcat监听端口 --> <port>8080</port> <!-- 配置项目的访问路径(Application Context) --> <path>/</path> </configuration> </plugin> </plugins> </build>