idea创建项目默认target bytecode version为1.5


 问题描述:

idea创建项目默认target bytecode version为1.5

手动将Project Settings => Modules ==>Language level改为8后

解决方案1:

1)手动将Project Settings => Modules ==>Language level改为8后

2)将Settings => Build,Execution,Deployment => Java Compiler的target bytecode version手动更改为1.8

)

3)重新reimport maven之后target bytecode version却仍然变为1.5

解决方案2:

在pom文件中加以下build,但是仍然没有效果

<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>

解决方案3:

发现是pom.xml中少了parent,则默认的target bytecode version为1.5

把注释去掉后则target bytecode version变为1.8

总结: 如果没有加parent,idea默认将target bytecode version设为1.5,并且自己手动改也不会改变。解决办法是加上parent

经验分享 程序员 微信小程序 职场和发展