最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】VSCode调试java报错:message: ‘<>‘ operator is not allowed for source level below 1.7

Java crifan 411浏览 0评论
折腾:
【未解决】VSCode中调试java报错:Build failed do you want to continue
期间,其中第一个error是:
!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
this.informosomes = new ArrayList<>();
java message: ‘<>’ operator is not allowed for source level below 1.7
java – How to fix ‘<>’operator is not allowed for source level 1.7 – Stack Overflow
说是,去更换java的target version?
比如别人说的pom.xml,确保
           <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
此处是vscode,去找找如何设置java的target version
java – openjdk 1.7 in eclipse: operator is not allowed for source level below 1.7 – Stack Overflow
java – How to fix ‘<>’ operator is not allowed for source level below 1.7 in 1.6? – Stack Overflow
java – Why <> operator is not allowed for source below 1.7? – Stack Overflow
eclipse报错: operator is not allowed for source level below 1.7_fulinwsuafcie的专栏-CSDN博客
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
‘<>’ operator is not allowed for source level below 1.7 · Issue #550 · redhat-developer/vscode-java · GitHub
和我问题一样:
我又没去指定 小于1.7版本的java
所以说是:配置有问题
别人说到:Maven 或  Gradle 或 Eclipse
看来需要设置这些,才能确保设置版本正常
Changing the Maven source, target works.
pom.xml
<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
参考:
GitHub – kasecato/vscode-javadebug-sample at maven-jetty
vscode-javadebug-sample/pom.xml at maven-jetty · kasecato/vscode-javadebug-sample · GitHub
Maven – Maven in 5 Minutes
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

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
85 queries in 0.111 seconds, using 20.59MB memory