我新安装了jdk11, 被将环境变量修改成了jdk11, 但是在idea运行Maven项目时, 报如下警告,java: 警告: 源发行版 11 需要目标发行版 11
时间: 2023-07-31 10:14:06 浏览: 172
这个警告是告诉你项目的编译级别和运行级别不一致,建议你检查一下你的项目设置,确保它们都使用 JDK 11。在 `pom.xml` 文件中,可以设置 `maven-compiler-plugin` 插件的 `source` 和 `target` 版本为 11,如下所示:
```xml
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>
```
另外,你也可以在 IDEA 中设置项目的 JDK 版本。可以按照如下步骤:
1. 点击菜单栏的 File -> Project Structure
2. 在弹出的窗口中,选择 Project
3. 在 Project SDK 下拉框中选择 JDK 11
4. 点击 OK,保存设置
这样设置后,你的项目应该就能正确编译和运行了。
阅读全文
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![txt](https://img-home.csdnimg.cn/images/20241231045021.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pptx](https://img-home.csdnimg.cn/images/20241231044947.png)
![7z](https://img-home.csdnimg.cn/images/20241231044736.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)