Al *_*rth 11 java macos maven visual-studio-code
我看到这个问题的很多答案,但它们对我不起作用。我在 PC 上安装了 Visual Studion Code、最新版本的 Java 和 Maven,并且能够在 PC 上使用 Maven 成功构建我的应用程序。然后我在 Mac 上执行了相同的步骤,但出现此错误。
Macos、Visual Studio Code、Maven 和 Java 的新版本。就像其他人所说的那样,我将这些行添加到我的 pom.xml 文件的属性部分:
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
Run Code Online (Sandbox Code Playgroud)
仍然得到同样的错误。这是 mvn 构建的相关输出:
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
Run Code Online (Sandbox Code Playgroud)
我也重新启动了 Visual Studio Code 无济于事。请让我知道还有哪些其他有用的信息。谢谢!
我使用的最后一个构建系统叫做 make,所以我已经有一段时间没有调试构建过程了。我也不记得转储 62Kb 的调试输出......
Anywho,搜索关键字“源”(线索是我应该添加的标签之一)让我在 maven 调试输出中找到了这个:
[调试] (f) 源 = 1.6
啊啊啊!源编译器版本并没有像我在原始问题中要求的那样改变!我敢打赌 Maven 人员更改了 xml 标记的位置!果然,在 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>
Run Code Online (Sandbox Code Playgroud)
我将源和目标标记值更改为 1.8 并且它起作用了!我还尝试删除构建插件范围中的源和目标标记,并将 maven.compiler.source/target 值设置为 1.8,这也有效。
故事如此寓意,请注意 pom.xml 文件中的额外源或目标标记!
小智 7
实际上,我也遇到了上述错误消息,将其添加到属性文件后,错误得到解决。:)
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
21664 次 |
| 最近记录: |