转载:http://blog.csdn.net/leo115/article/details/8187451
Maven工程打包时出现 [INFO] Compilation failure;
[ERROR] COMPILATION ERROR
问题解决办法
- [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 failure
- D:\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 鎴栨洿楂樼増鏈互鍚敤娉ㄩ噴锛?
- @Controller
- D:\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 鎴栨洿楂樼増鏈互鍚敤娉ㄩ噴锛?
- @Override
- D:\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版本
依赖的Java 版本是1.6.0_10-rc2
- Maven version: 2.0.10
- Java version: 1.6.0_10-rc2
- OS name: "windows xp" version: "5.1" arch: "x86" Family: "windows"
(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 命令,第一遍可能还会出现错误,多执行几遍,便会打包成功,(一般执行第二遍时即可打包成功)。
相关推荐
在使用IntelliJ IDEA(简称Idea)进行Java开发时,有时会遇到“Error:java: Compilation failed: internal java compiler error”的错误提示,这通常意味着编译过程中遇到了内部错误,可能是由于配置问题、环境问题...
Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean (default-clean) on project
[ERROR] COMPILATION ERROR : Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure 解决方法 1. 分析依赖关系:可以使用以下命令来分析依赖关系:`mvn -X dependency:...
【标题】:“idea: 不支持发行版本 5 11 12 13 compilation failed: internal java compiler error” 在编程开发过程中,我们经常会遇到IDE(集成开发环境)与Java编译器之间的兼容性问题。这里的问题是 IntelliJ ...
- **依赖管理支持:**支持Maven和Ivy等流行依赖管理系统,确保项目依赖能够被妥善管理和更新。 - **高度灵活性:**虽然提供了最佳实践方案,但并不强制使用特定的方法或框架,给予开发者充分的自由度。 - **强大...