哎,
问题现象:
private Map<String, BeanDefinition> beanDefinitionMap = new HashMap<>();
正常情况下这个是可以写的,但是idea爆红,想必爆红,就需要我们去解决
此时,我们去看一下项目的版本
发现变成了JDK5了,这是为什么呀???
然后我们改回去,改到JDK1.8
是不是挺无语的。。。。。。
解决办法:
第一种(最省事):在我们安装maven环境的conf目录下修改settings.xml文件,如下:
在profiles中加入以下配置。
<profile>
<id>jdk-1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
第二种:在我们开发工具idea中添加配置也可以实现,具体配置如下:
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
第三种:还是在idea中添加配置,和第二种不一样的是我们通过maven的插件实现,
具体配置如下:
<build>
<plugins>
<!-- 设置编译版本 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
三种方式均可实现指定JDK版本,第一种最省事,不过以后创建的maven项目都会默认
选择JDK1.8了,在开发中我们可以自己在pom文件中配置,可以随时切换JDK版本。