dal*_*ski 11 java intellij-idea intellij-14
对于我目前正在处理的项目,IntelliJ给了我编译错误Error:java: javacTask: source release 8 requires target release 1.8.我进入设置>构建,执行,部署>编译器> Java,看到我的一个模块的目标字节码版本设置为1.5,所以我将其更改为1.8,编译,并且它工作.但第二天,我得到了同样的错误.我进入了设置,那个模块的目标字节码又回到了1.5.我把它改为1.8,它编译/运行得很好.这已经发生了多次,我对设置手动更改目标字节码版本的次数感到沮丧.
为什么目标字节码版本会保持还原?我没有在pom或其他任何地方指定1.5,所以我很困惑为什么字节码版本一直设置为1.5.
你需要把它给你的POM:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
您需要在pom.xml文件中指定源版本和目标版本,但由于maven-compiler-plugin默认情况下已添加,因此更简单的方法是设置以下属性:
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3550 次 |
| 最近记录: |