环境介绍:

Windows10专业版、IDEA2020.1、Maven3.6.3、Java11

IDEA2020.1下载地址:https://www.jetbrains.com/ 官网下载对应版本即可

Maven3.6.3下载地址:http://maven.apache.org/download.cgi 官网下载对应版本即可

Maven安装后配置环境变量:

IDEA2020.1配置Maven3.6.3

IDEA2020.1配置Maven3.6.3

如果你想在本地安装多个版本的Maven,可以使用如图的方式,分别定义对应版本的变量名,然后MAVEN_HOME指向你需要使用版本的变量名即可,如果只安装一个版本则直接在MAVEN_HOME变量名中指定其变量值即可。

修改Maven安装目录${MAVEN_HOME}\conf\setting.xml

示例(3.6.3为例):

在<mirrors></mirrors>标签中添加在如下:

<mirror>
      <id>aliyunmaven</id>
      <mirrorOf>*</mirrorOf>
      <name>阿里云公共仓库</name>
      <url>https://maven.aliyun.com/repository/public</url>
    </mirror>
    <mirror>
      <id>alimaven</id>
      <name>aliyun maven</name>
      <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
      <mirrorOf>central</mirrorOf>        
    </mirror>

在<profiles></profiles>标签中添加如下(使用的JDK1.8):

<profile>
      <id>jdk-11</id>
      <activation>
      <activeByDefault>true</activeByDefault>
        <jdk>11</jdk>
      </activation>
      <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
        <maven.compiler.compilerVersion>11</maven.compiler.compilerVersion>
      </properties>
    </profile>

在<settings></settings>标签中添加本地仓库目录:

<localRepository>E:\ProgramData\.m2_maven\repository</localRepository>

注意:如果你使用的是Java11及以上的环境,那么

标签<localRepository></localRepository>不再需要配置了,在IDEA中使用时在指定对应的本地仓库目录

 

IDEA(2020.1)中配置Maven3.6.3:

IDEA2020.1配置Maven3.6.3

这里对应前面的注意部分

重点来了

IDEA2020.1配置Maven3.6.3

IDEA2020.1配置Maven3.6.3

需要配置如上两图部分的VM Options:

-Xmx768m -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=true

否则IDEA在新建Maven项目时会报错:

Plugin org.apache.maven.plugins:maven-archetype-plugin:RELEASE or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-archetype-plugin:jar:RELEASE: Failed to resolve version for org.apache.maven.plugins:maven-archetype-plugin:jar:RELEASE: Could not find metadata org.apache.maven.plugins:maven-archetype-plugin/maven-metadata.xml in local (E:\ProgramData\.m2_maven\repository) -> [Help 1

如果IDEA在新建Maven项目后下载对应插件时报警告:

No archetype found in remote catalog. Defaulting to internal catalog

只需要在新建项目时添加一个变量即可(不过只是报警告,不理会也没关系)

IDEA2020.1配置Maven3.6.3

这面往后的新建项目就不会有任何错误和警告了。

 

相关文章:

  • 2021-12-12
  • 2022-03-08
  • 2022-12-23
  • 2021-05-27
  • 2021-06-24
  • 2021-04-11
  • 2021-08-28
  • 2021-10-28
猜你喜欢
  • 2021-06-22
  • 2021-10-25
  • 2022-12-23
  • 2022-12-23
  • 2021-10-27
  • 2021-11-19
  • 2021-07-25
相关资源
相似解决方案