[英]Maven compilation (java8 compatibility java6)
I have problem with my maven build because recently we have changed our java. 我的Maven版本有问题,因为最近我们更改了Java。
I launch maven build with java8 and I want my code to compile with java6. 我使用java8启动maven build,并且希望我的代码能够使用java6进行编译。 So for this I added this to my pom: 因此,为此我将其添加到了pom中:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<optimize>true</optimize>
<compilerVersion>1.6</compilerVersion>
<compilerId>eclipse</compilerId>
<executable>${JAVA_1_6_HOME}/bin/javac</executable>
<verbose>true</verbose>
<fork>true</fork>
<debug>true</debug>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-eclipse</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-api</artifactId>
<version>2.1</version>
</dependency>
</dependencies>
</plugin>
But when I launch maven build I have this error which only exists in java8 (Duplicate methods named spliterator with the parameters () and () are inherited from the types List<T>
and Collection<T>
). 但是,当我启动maven build时,我遇到了仅在java8中存在的错误(名为spliterator且参数为()和()的重复方法继承自List<T>
和Collection<T>
)。
Do you have any idea why my code seems to be compile with java8? 您知道为什么我的代码似乎可以用java8编译吗?
(part of logs) (部分日志)
(f) compilerId = eclipse
[DEBUG] (f) compilerVersion = 1.6
[DEBUG] (f) debug = true
[DEBUG] (f) encoding = UTF-8
[DEBUG] (f) executable = C:\Program Files\Java60\java\bin\javac
[DEBUG] (f) failOnError = true
[DEBUG] (f) forceJavacCompilerUse = false
[DEBUG] (f) fork = true
I think you should use compiler from java 8. Now you hardcoded ${JAVA_1_6_HOME}/bin/javac
. 我认为您应该使用Java 8的编译器。现在,您已对${JAVA_1_6_HOME}/bin/javac
硬编码。 Use something like: ${JAVA_1_8_HOME}/bin/javac
使用类似的东西: ${JAVA_1_8_HOME}/bin/javac
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.