Maven与IDEA版本兼容问题以及配置在创建Maven项⽬或者SpringBoot项⽬的时候,需要配置Maven插件。它能够为我们⾃动提供依赖,只需要⼏⾏代码提供jar包的坐标即可,⽽不⽤像以前那样疯狂导包,消耗多余的内存。
maven版本与idea版本存在兼容性问题,版本不兼容就会报⽆法导⼊maven项⽬的问题。
Unable to import maven project: See logs for details
2018版本只兼容Maven3.6.1之前的版本,对于之后的版本不兼容。
进⼊官⽹后可以看到⽬前maven的版本已经更新到了3.8.1,这个版本兼容的IDEA版本是2021,下载Maven3.6.1的步骤如下:        ⾸先点击Previous Releases⾥⾯的archives标签,进⼊maven3的索引页⾯
然后点击3.6.1版本,进⼊3.6.1的索引页⾯。
再点击binaries,进⼊binaries⽬录。最后windows系统点击apache-maven-3.6.1-bin.zip就可以开始下载maven3.6.1的压缩包了。
下载完成后,将压缩包解压到电脑上存放软件开发⼯具的⽬录。然后进⾏maven插件的环境变量的配置。        创建两个⽤户变量:
点击确定。打开命令提⽰符:输⼊mvn -v检查maven环境变量是否配置成功。
Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-05T03:00:29+08:00)
Maven home: D:\DevelopTools\apache-maven-3.6.1\bin\..
Java version: 1.8.0_131, vendor: Oracle Corporation, runtime: D:\DevelopTools\jdk-1.8.0\jre
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
环境变量配置完成后,进⾏maven的配置⽂件l的配置。
第⼀步:打开maven解压⽬录下的D:\DevelopTools\apache-maven-3.6.1\l⽂件。在 <!--< localRepository> </ localRepository>-->标签下配置本地仓库的地址,建议新建⼀个本地仓库⽬录进⾏配置。
<settings xmlns="/SETTINGS/1.0.0"
xmlns:xsi="/2001/XMLSchema-instance"李易峰新经纪人
xsi:schemaLocation="/SETTINGS/1.0.0 /xsd/settings-1.0.0.xsd">
<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository
-->
<localRepository>D:\DevelopTools\LocalRepository</localRepository>
第⼆步:为了使maven能够⾃动从中央仓库下载需要的jar包,我们需要给它配置阿⾥云镜像仓库:在  l ⽂件的标
<mirrors></mirrors>标签⾥⾯配置以下标签:
<mirrors>
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
|
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>my.repository/repo/path</url>
</mirror>
-->
<mirrors>
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>maven.aliyun/nexus/content/groups/public</url>
</mirror>
</mirrors>
</mirrors>
第三步:将maven项⽬创建的默认依赖JDK版本改为1.8.
我的麦克风<profiles>
<!-- profile
| Specifies a set of introductions to the build process, to be activated using one or more of the
| mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>
| or the command line, profiles have to have an ID that is unique.
|
| An encouraged best practice for profile identification is to use a consistent naming convention
| for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
| This will make it more intuitive to understand what the set of introduced profiles is attempting
| to accomplish, particularly when you only have a list of profile id's for debug.
张碧晨男朋友
|this is it 下载
| This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
<profile>
<id>jdk-1.4</id>
陈柏霖个人资料<activation>
<jdk>1.4</jdk>
</activation>
<repositories>
<repository>
<id>jdk14</id>
<name>Repository for JDK 1.4 builds</name>
<url>host/maven/jdk14</url>
<layout>default</layout>
<snapshotPolicy>always</snapshotPolicy>
</repository>
</repositories>
</profile>
-->
<profiles>
<profile>
<id>jdk-1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<mavenpiler.source>1.8</mavenpiler.source>李宏毅的哥哥
<mavenpiler.target>1.8</mavenpiler.target>
<mavenpilerpilerVersion>1.8</mavenpilerpilerVersion>
</properties>
</profile>
</profiles>
最后修改maven插件的设置,选择⾃⼰安装的maven,不使⽤IDEA⾃带的maven插件。图中的版本应该为我们安装的3.6.1。