1.加入插件,修改版本就行了
<plugin> <span style="white-space:pre"> </span><groupId>org.apache.maven.plugins</groupId> <span style="white-space:pre"> </span><artifactId>maven-compiler-plugin</artifactId> <span style="white-space:pre"> </span><version>3.3</version> <span style="white-space:pre"> </span><configuration> <span style="white-space:pre"> </span><source>1.7</source> <span style="white-space:pre"> </span><target>1.7</target> <span style="white-space:pre"> </span></configuration> <span style="white-space:pre"> </span></plugin>
需要刷新project,后面的都是记录
2.运行package:
[INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building WebTest Maven Webapp 0.0.1-SNAPSHOT [INFO] ------------------------------------------------------------------------ [WARNING] The artifact servletapi:servletapi:jar:2.4 has been relocated to javax.servlet:servlet-api:jar:2.4 [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ WebTest --- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ WebTest --- [INFO] Changes detected - recompiling the module! [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! [INFO] Compiling 1 source file to D:\all\eclipse432\WebTest\target\classes [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ WebTest --- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory D:\all\eclipse432\WebTest\src\test\resources [INFO] [INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) @ WebTest --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ WebTest --- [INFO] [INFO] --- maven-war-plugin:2.2:war (default-war) @ WebTest --- [INFO] Packaging webapp [INFO] Assembling webapp [WebTest] in [D:\all\eclipse432\WebTest\target\WebTest] [INFO] Processing war project [INFO] Copying webapp resources [D:\all\eclipse432\WebTest\src\main\webapp] [INFO] Webapp assembled in [74 msecs] [INFO] Building war: D:\all\eclipse432\WebTest\target\WebTest.war [INFO] WEB-INF\web.xml already added, skipping [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.818 s [INFO] Finished at: 2016-05-11T02:34:46+08:00 [INFO] Final Memory: 16M/167M [INFO] ------------------------------------------------------------------------
3.完整pom记录:
<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>org.ms.bop</groupId> <artifactId>WebTest</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>WebTest Maven Webapp</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>servletapi</groupId> <artifactId>servletapi</artifactId> <version>2.4</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version>2.2</version> <scope>provided</scope> </dependency> <!-- <dependency> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> </dependency> --> </dependencies> <build> <finalName>WebTest</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.3</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> <!-- <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>8.1.16.v20140903</version> <configuration> <scanIntervalSeconds>5</scanIntervalSeconds> <webApp> <contextPath>/WebTest</contextPath> </webApp> </configuration> </plugin> --> </plugins> </build> </project>
时间: 2024-10-24 23:44:45