[英]Another Maven "Source option 6 is no longer supported. Use 7 or later."
I see lots of answers to this question but they don't work for me.我看到很多关于这个问题的答案,但它们对我不起作用。 I installed Visual Studio Code, latest version of Java and Maven on my PC and I was able to successfully build my application with Maven on the PC.
我在我的 PC 上安装了 Visual Studio Code,最新版本的 Java 和 Maven,我能够在 PC 上使用 Maven 成功构建我的应用程序。 I then went through the same steps on my Mac and I get this error.
然后我在我的 Mac 上完成了相同的步骤,我得到了这个错误。
Fresh versions of Macos, Visual Studio Code, Maven and Java. Macos、Visual Studio Code、Maven 和 Java 的新版本。 Like all the others have said, I added these lines to the properties section of my pom.xml file:
就像所有其他人所说的那样,我将这些行添加到我的 pom.xml 文件的属性部分:
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
Still get the same error.仍然得到同样的错误。 Here is the relevant output from the mvn build:
这是来自 mvn 构建的相关 output:
alberts-mbp:com.versabuilt.rushmore.process albertyoungwerth$ mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] ---------< com.versabuilt.rushmore.process:VersaBuiltProcess >----------
[INFO] Building VersaBuilt Process 0.2.18
[INFO] -------------------------------[ bundle ]-------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ VersaBuiltProcess ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 5 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.6.0:compile (default-compile) @ VersaBuiltProcess ---
[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 10 source files to /Users/albertyoungwerth/rushmore/com.versabuilt.rushmore.process/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] Source option 6 is no longer supported. Use 7 or later.
[ERROR] Target option 6 is no longer supported. Use 7 or later.
[INFO] 2 errors
I have also restarted Visual Studio Code to no avail.我也重新启动了 Visual Studio Code,但无济于事。
The last build system I used was called make, so it's been a while since I debugged a build process.我使用的最后一个构建系统称为 make,所以我已经有一段时间没有调试构建过程了。 I don't remember make dumping 62Kb of debug output either...
我也不记得要转储 62Kb 的调试 output ...
Anywho, searching for the keyword "source" (clue being that was one of the tags I was supposed to add) got me to this in the maven debug output:在 maven 调试 output 中搜索关键字“源”的任何人(线索是我应该添加的标签之一):
[DEBUG] (f) source = 1.6 [调试] (f) 源 = 1.6
Ahaaa, the source compiler version had not changed like I asked it to with the edit in my original question.啊哈,源编译器版本并没有像我在原始问题中的编辑所要求的那样改变。 I'll bet the maven folks changed the location of the xml tag.
我敢打赌 maven 的人改变了 xml 标签的位置。 Sure enough: searching for 1.6 in the pom.xml file I find this:
果然:在 pom.xml 文件中搜索 1.6 我发现了这个:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
I changed the source and target tag values to 1.8 and it worked.我将源和目标标记值更改为 1.8 并且它工作。 I also tried deleting the source and target tags in the build plugins scope and left in the maven.compiler.source/target values set to 1.8 and that also worked.
我还尝试删除构建插件 scope 中的源和目标标签,并将 maven.compiler.source/target 值设置为 1.8,这也有效。
So moral of the story, be careful of extra source or target tags in your pom.xml file!故事的寓意,请注意 pom.xml 文件中的额外源或目标标签!
Actually, I too faced the above error message, after adding this to property file, Error got resolved.实际上,我也遇到了上述错误消息,将其添加到属性文件后,错误得到了解决。 :)
:)
property need to be added in pom.xml需要在 pom.xml 中添加属性
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
I corrected this problem by matching the jdk between my IDE and the pom.xml file.我通过匹配我的 IDE 和 pom.xml 文件之间的 jdk 纠正了这个问题。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
Sometimes changing from Kotlin to java or inverted.有时从 Kotlin 更改为 java 或倒置。
You can also change or java version to a higher one.您也可以将 java 版本更改为更高版本。
At least that worked for me.至少这对我有用。
Changing maven compiler version in pom file solved my issue.在 pom 文件中更改 maven 编译器版本解决了我的问题。
<maven.compiler.source>11</maven.compiler.source> <maven.compiler.target>11</maven.compiler.target>
go to your project properties and go to sources. go 到您的项目属性和 go 到源。 then in Source/binary format it will be JDK 5 or 6 etc. but click and make it the higher version.
然后在源代码/二进制格式中,它将是 JDK 5 或 6 等,但单击并使其成为更高版本。 you are done.:)
你完成了。:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.