注意:maven在默認是用jdk1.5版原本編譯java文件java
想要改變其默認設置,能夠經過添加插件方式web
如下是pom.xml文件配置apache
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <!-- 組織名 --> <groupId>com.chinasofti</groupId> <!-- 工程名 --> <artifactId>web01</artifactId> <!-- 打包類型 --> <packaging>war</packaging> <!-- 版本 --> <version>0.0.1-SNAPSHOT</version> <name>web01 Maven Webapp</name> <url>http://maven.apache.org</url> <!-- 指定依賴jar --> <dependencies> <!-- junit單元測試 --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.10</version> <!-- test 僅測試時依賴該jar compile 編譯期使用 --> <scope>test</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.0.1</version> <scope>compile</scope> </dependency> <dependency> <groupId>com.chinasofti</groupId> <artifactId>commons</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency> </dependencies> <build> <!-- finalName指定打包生成的文件名,默認爲工程名-版本號 --> <finalName>web01</finalName> <plugins> <!-- 指定jdk版本 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <!-- 源碼的編譯器版本 --> <source>1.8</source> <!-- class的編譯器版本 --> <target>1.8</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <!-- 跳過測試 --> <skip>true</skip> </configuration> <version>2.18.1</version> </plugin> </plugins> </build> </project>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <!-- 組織名 --> <groupId>com.chinasofti</groupId> <!-- 工程名 --> <artifactId>web01</artifactId> <!-- 打包類型 --> <packaging>war</packaging> <!-- 版本 --> <version>0.0.1-SNAPSHOT</version> <name>web01 Maven Webapp</name> <url>http://maven.apache.org</url> <!-- 指定依賴jar --> <dependencies> <!-- junit單元測試 --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.10</version> <!-- test 僅測試時依賴該jar compile 編譯期使用 --> <scope>test</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.0.1</version> <scope>compile</scope> </dependency> <dependency> <groupId>com.chinasofti</groupId> <artifactId>commons</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency> </dependencies> <build> <!-- finalName指定打包生成的文件名,默認爲工程名-版本號 --> <finalName>web01</finalName> <plugins> <!-- 指定jdk版本 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <!-- 源碼的編譯器版本 --> <source>1.8</source> <!-- class的編譯器版本 --> <target>1.8</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <!-- 跳過測試 --> <skip>true</skip> </configuration> <version>2.18.1</version> </plugin> </plugins> </build> </project>