这两天使用eclipse创建maven项目,总是默认使用的老版本jdk,这让我很烦躁,网上有很多修改的帖子,今天突然有兴致,决定在自己的博客记录一下;
在自己的maven安装目录总找到conf/settings.xml,在profile区添加如下配置:
<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> |
然后在eclipse-Preferences-Maven-User Settings,指定刚才编辑的settings.xml,
,
图中Global Settings和User Setttings设置哪一个都可以,二者的区别是Global Settings通常配置的是你maven安装目录下cnof下的settings.xml文件,User Setttings是当前工作空间的,比如我们当前项目依赖的maven本地仓库不在.m2/下,我们可以通过复制maven安装目录conf/settings.xml到你想要指定的仓库位置,编辑文件添加
<localRepository>这里是你仓库目录的全路径</localRepository> |
,然后配置User Settings指向刚才所编辑的settings文件;
粗浅理解,纯粹个人笔记,希望能对他人有点帮助!
如有讲解错误,请留言指正,不胜感激!!!