我已经将一个maven项目导入了intellij IDEA。依赖关系已成功解决。但是在运行时
sudo mvn install
来自终端的会出现此错误。
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure
/media/Academic/Work/Project/InputAdapter/IDEAInputEventAdapter/testIn/org.wso2.event.adaptor.testIn/src/main/java/org/wso2/event/adaptor/testIn/TestInEventAdaptorFactory.java:[24,5] error: annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
/media/Academic/Work/Project/InputAdapter/IDEAInputEventAdapter/testIn/org.wso2.event.adaptor.testIn/src/main/java/org/wso2/event/adaptor/testIn/TestInEventAdaptorType.java:[40,5] error: annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
/media/Academic/Work/Project/InputAdapter/IDEAInputEventAdapter/testIn/org.wso2.event.adaptor.testIn/src/main/java/org/wso2/event/adaptor/testIn/TestInEventAdaptorType.java:[46,18] error: generics are not supported in -source 1.3
此前我已将此项目导入eclipse。然后从eclipse运行mvn install它给出了一种不同类型的错误。
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure
error: error reading /home/asiri/.m2/repository/com/hazelcast/hazelcast/3.0.1/hazelcast-3.0.1.jar; invalid LOC header (bad signature)
error: error reading /home/asiri/.m2/repository/org/eclipse/equinox/org.eclipse.equinox.http.helper/1.1.0.wso2v1/org.eclipse.equinox.http.helper-1.1.0.wso2v1.jar; zip file is empty
error: error reading /home/asiri/.m2/repository/org/apache/ws/commons/axiom/axiom-api/1.2.11/axiom-api-1.2.11.jar; invalid CEN header (bad signature)
error: error reading /home/asiri/.m2/repository/commons-io/commons-io/2.0/commons-io-2.0.jar; invalid LOC header (bad signature)
error: error reading /home/asiri/.m2/repository/org/wso2/carbon/org.wso2.carbon.user.core/4.2.0/org.wso2.carbon.user.core-4.2.0.jar; error in opening zip file
error: error reading /home/asiri/.m2/repository/org/apache/poi/poi-scratchpad/3.9/poi-scratchpad-3.9.jar; invalid LOC header (bad signature)
error: error reading /home/asiri/.m2/repository/org/apache/poi/poi/3.9/poi-3.9.jar; invalid LOC header (bad signature)
error: error reading /home/asiri/.m2/repository/commons-pool/commons-pool/1.5/commons-pool-1.5.jar; invalid LOC header (bad signature)
error: error reading /home/asiri/.m2/repository/org/apache/tomcat/tomcat-tribes/7.0.34/tomcat-tribes-7.0.34.jar; invalid LOC header (bad signature)
error: error reading /home/asiri/.m2/repository/org/apache/tomcat/tomcat-catalina/7.0.34/tomcat-catalina-7.0.34.jar; invalid CEN header (bad signature)
error: error reading /home/asiri/.m2/repository/org/wso2/carbon/org.wso2.carbon.authenticator.stub/4.2.0/org.wso2.carbon.authenticator.stub-4.2.0.jar; error in opening zip file
error: error reading /home/asiri/.m2/repository/com/google/code/gson/gson/2.1/gson-2.1.jar; invalid LOC header (bad signature)
error: error reading /home/asiri/.m2/repository/org/apache/httpcomponents/wso2/httpclient/4.1.1-wso2v1/httpclient-4.1.1-wso2v1.jar; error in opening zip file
error: error reading /home/asiri/.m2/repository/com/google/guava/guava/12.0/guava-12.0.jar; invalid CEN header (bad signature)
在运行
之后 sudo mvn install
来自终端的可以获得成功。 我不明白这种行为的原因。如果有一种方法来解决问题的第一部分中的错误,那将真的有帮助。
答案 0 :(得分:3)
请参阅Maven Compiler Plugin Documentation。设置正确的源和目标级别。那应该解决它。
答案 1 :(得分:2)
听起来像您的编译器插件配置不完整
你的Jdk等级应该大于1.5
示例pom.xml配置
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
答案 2 :(得分:1)
只需像这样定义编译器目标/源:
<project>
[...]
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
[...]
</build>
[...]
</project>
注释至少需要1.5。
答案 3 :(得分:1)
在pom.xml中搜索“source” 必须有错误的价值 Source表示编译代码的Java版本 如果Java代码中有注释,则需要设置版本&gt; = 1.5