折腾:
【未解决】VSCode中调试java报错:Build failed do you want to continue
期间,其中第一个error是:
1 2 | !MESSAGE Error occured while building workspace. Details: message: '<>' operator is not allowed for source level below 1.7; code: 16778099; resource: /Users/crifan/dev/dev_root/projects/xxx/src/refer/java/iec_analysis/src/main/java/com/iec/assemble101/ContinuousAddressBuilder .java; line: 48 |
所以去看看代码
发现问题 中也有:

点击进去看看代码
src/refer/java/iec_analysis/src/main/java/com/iec/assemble101/ContinuousAddressBuilder.java
1 | this.informosomes = new ArrayList<>(); |

java message: ‘<>’ operator is not allowed for source level below 1.7
说是,去更换java的target version?
比如别人说的pom.xml,确保
1 2 3 4 | < configuration > < source >1.8</ source > < target >1.8</ target > </ configuration > |
此处是vscode,去找找如何设置java的target version
vscode java message: ‘<>’ operator is not allowed for source level below 1.7
vscode message: ‘<>’ operator is not allowed for source level below 1.7
和我问题一样:
我又没去指定 小于1.7版本的java
所以说是:配置有问题
别人说到:Maven 或 Gradle 或 Eclipse
看来需要设置这些,才能确保设置版本正常
Changing the Maven source, target works.
pom.xml
1 2 3 4 5 6 7 8 | < project > [...] < properties > < maven.compiler.source >1.8</ maven.compiler.source > < maven.compiler.target >1.8</ maven.compiler.target > </ properties > [...] </ project > |
想起来了,先去解决:
【已解决】VSCode调试Java弹框提示:Maven executable not found in PATH Please specifiy maven.executable.path in Settings
参考:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 1. < project xmlns = "http://maven.apache.org/POM/4.0.0" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" 2. xsi:schemaLocation = "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" > 3. < modelVersion >4.0.0</ modelVersion > 4. 5. < groupId >com.mycompany.app</ groupId > 6. < artifactId >my-app</ artifactId > 7. < version >1.0-SNAPSHOT</ version > 8. 9. < properties > 10. < maven.compiler.source >1.7</ maven.compiler.source > 11. < maven.compiler.target >1.7</ maven.compiler.target > 12. </ properties > 13. 14. < dependencies > 15. < dependency > 16. < groupId >junit</ groupId > 17. < artifactId >junit</ artifactId > 18. < version >4.12</ version > 19. < scope >test</ scope > 20. </ dependency > 21. </ dependencies > 22. </ project > |
官网的示例配置中都有这个source和target
然后去修改pom.xml
然后VSCode发现有改动,自动提示:
A build file was modified. Do you want to synchronize the Java classpath/configuration?
来源:Language Support for Java(TM) by RedHat (扩展)

点击 Always
这样以后每次就自动更新了。
然后注意到:
会自动重新编译整个项目文件
然后
之前问题有130个 + 左边项目文件很多红色的错误:

现在问题减少到120个了 + 且几个核心文件的红色错误也没了,只有黄色警告⚠️,而不是红色了:

转载请注明:在路上 » 【已解决】VSCode调试java报错:message: ‘<>‘ operator is not allowed for source level below 1.7