vscode java开发抽风

代码写完, 就是不能跑,
由于我这个项目是从其它地方复制过来的老项目, 改了个项目名字… 然后再继续用, 发现跑步起来了.
当所有的错误都被解决用maven可以编译通过. 开启启动调试,却仍然报错如下

Preview features enabled at an invalid source release level 16, preview can be enabled only at source level 17

百度得到结果如下:

1.ctrl + shift + p.
2.Write to the command palette: Clean the Java language server workspace.
3.Press enter (restart your VScode).

经试验无效.

后来,

删除了项目目录下 .vscode文件夹, 重新用vscode打开文件夹就正常了.

后来发现还是不行, 还是会提示. 这个错误.

后来把pom.xml中的.
pom.xml

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration> 
                <skip>true</skip> 
                <source>16</source>
                <target>16</target>
                <skipTests>true</skipTests>  
                <!--                    <release>16</release>-->
                <fork>true</fork>
                <compilerArgs>
                     <arg>--enable-preview</arg>
                    <arg>-Xlint:all</arg>
                    <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>
                    <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED</arg>
                    <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg>
                    <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</arg>
                    <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED</arg>
                    <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</arg>
                    <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED</arg>
                    <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg>
                    <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg>
                    <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED</arg>
                </compilerArgs>
                <!--for unmappable characters in classes-->
                <encoding>UTF-8</encoding>
                <showDeprecation>true</showDeprecation>
                <showWarnings>true</showWarnings>
                <!--for lombok annotations to resolve-->
                <!--contradictory to maven, intelliJ fails with this-->
                <testFailureIgnore>true</testFailureIgnore> 
                <annotationProcessorPaths>
                    <path>
                        <groupId>org.projectlombok</groupId>
                        <artifactId>lombok</artifactId>
                        <version>1.18.20</version>
                    </path>
                </annotationProcessorPaths>
            </configuration>
        </plugin>
      </plugins>
<arg>--enable-preview</arg> 

这个参数给去掉就行了

另外 下面的这两个参数也一定要写对.

<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值