Maven工程打包时出现 [INFO] Compilation failure 问题解决办法

来源:互联网 发布:软件项目介绍费 编辑:程序博客网 时间:2024/05/17 18:01
[INFO] Scanning for projects...[INFO] ------------------------------------------------------------------------[INFO] Building brandCtr Maven Webapp[INFO]    task-segment: [package][INFO] ------------------------------------------------------------------------[INFO] [resources:resources][WARNING] Using platform encoding (utf-8 actually) to copy filtered resources, i.e. build is platform dependent![INFO] Copying 2 resources[WARNING] POM for 'org.springframework:spring-transaction:pom:3.0.5.RELEASE:compile' is invalid. It will be ignored for artifact resolution. Reason: Failed to validate POM for project org/springframework:spring-transaction at Artifact [org.springframework:spring-transaction:pom:3.0.5.RELEASE:compile][WARNING] POM for 'org.springframework:spring-transaction:pom:3.0.5.RELEASE:compile' is invalid. It will be ignored for artifact resolution. Reason: Failed to validate POM for project org/springframework:spring-transaction at Artifact [org.springframework:spring-transaction:pom:3.0.5.RELEASE:compile][INFO] [compiler:compile][INFO] Compiling 9 source files to D:\eclipse-jee\workspace\brandCtr\target\classes[INFO] ------------------------------------------------------------------------[ERROR] BUILD FAILURE[INFO] ------------------------------------------------------------------------[INFO] Compilation failureD:\eclipse-jee\workspace\brandCtr\src\main\java\dao\IQueryDAO.java:[12,5] -source 1.3 涓笉鏀寔娉涘瀷锛堣浣跨敤 -source 5 鎴栨洿楂樼増鏈互鍚敤娉涘瀷锛?List<Adzone> getAdzoneListByTimeList(List<Integer> timeList);D:\eclipse-jee\workspace\brandCtr\src\main\java\util\TimeUtil.java:[36,19] -source 1.3 涓笉鏀寔娉涘瀷锛堣浣跨敤 -source 5 鎴栨洿楂樼増鏈互鍚敤娉涘瀷锛?public static List<Integer> getResentTimeList(int days) {D:\eclipse-jee\workspace\brandCtr\src\main\java\web\QueryController.java:[29,1] -source 1.3 涓笉鏀寔娉ㄩ噴锛堣浣跨敤 -source 5 鎴栨洿楂樼増鏈互鍚敤娉ㄩ噴锛?@ControllerD:\eclipse-jee\workspace\brandCtr\src\main\java\web\QueryController.java:[65,6] -source 1.3 涓笉鏀寔娉涘瀷锛堣浣跨敤 -source 5 鎴栨洿楂樼増鏈互鍚敤娉涘瀷锛?List<Integer> timeList = TimeUtil.getResentTimeList(days);D:\eclipse-jee\workspace\brandCtr\src\main\java\web\QueryController.java:[72,21] -source 1.3 涓笉鏀寔 for-each 寰幆锛堣浣跨敤 -source 5 鎴栨洿楂樼増鏈互鍚敤 for-each 寰幆锛?for (Adzone adzone : adzoneList) {D:\eclipse-jee\workspace\brandCtr\src\main\java\dao\QueryDAOImpl.java:[19,2] -source 1.3 涓笉鏀寔娉ㄩ噴锛堣浣跨敤 -source 5 鎴栨洿楂樼増鏈互鍚敤娉ㄩ噴锛?@OverrideD:\eclipse-jee\workspace\brandCtr\src\main\java\dao\QueryDAOImpl.java:[20,12] -source 1.3 涓笉鏀寔娉涘瀷锛堣浣跨敤 -source 5 鎴栨洿楂樼増鏈互鍚敤娉涘瀷锛?public List<Adzone> getAdzoneListByTimeList(List<Integer> timeList){D:\eclipse-jee\workspace\brandCtr\src\main\java\dao\QueryDAOImpl.java:[23,19] -source 1.3 涓笉鏀寔 for-each 寰幆锛堣浣跨敤 -source 5 鎴栨洿楂樼増鏈互鍚敤 for-each 寰幆锛?for(Adzone adzone:adzoneList){[INFO] ------------------------------------------------------------------------[INFO] For more information, run Maven with the -e switch[INFO] ------------------------------------------------------------------------[INFO] Total time: 1 second[INFO] Finished at: Thu Nov 15 16:23:12 CST 2012[INFO] Final Memory: 11M/20M[INFO] ------------------------------------------------------------------------

问题解析:

该错误是由于maven编译的时候使用了jdk1.3,而jdk1.3不支持泛型;

solution:

(1) 使用mvn -v 查看Maven版本

Maven version: 2.0.10Java version: 1.6.0_10-rc2OS name: "windows xp" version: "5.1" arch: "x86" Family: "windows"
依赖的Java 版本是1.6.0_10-rc2

(2)maven2.0.10默认使用的是jdk1.3,而当前Maven要依赖 1.6版本,

解决办法:

可知原工程在 编译(compile)的阶段出现问题,检查 Maven 依赖的POM.XML文件中是否配置有 Maven编译的插件

如果没有可按如下配置编译插件

<build> <plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><configuration><source>1.6</source><target>1.6</target></configuration></plugin></plugins><finalName>brandCtr</finalName></build>

配置好之后,重新在命令行中执行 mvn package 命令,第一遍可能还会出现错误,多执行几遍,便会打包成功,(一般执行第二遍时即可打包成功)。

注:可以参看这篇blog:http://binma85.iteye.com/blog/1092758