美文网首页
解决IDEA中创建maven工程相关问题

解决IDEA中创建maven工程相关问题

作者: yaco | 来源:发表于2020-04-06 12:32 被阅读0次

Maven下载安装及配置

新手上路,被maven的各种问题整的很是烦恼,写一份自己走通的配置方法。

1 Maven的下载安装

  • 下载地址 https://maven.apache.org/download.cgi#

  • 最新版本为3.6.3,旧版本可点击archives

  • 我下的是3.6.1, 直接将安装本解压缩到指定目录即可

  • 配置maven的环境变量,变量值即为解压缩的文件路径


  • 添加到path路径


  • 以上就完成了整个Maven的配置

2 maven仓库配置和镜像下载地址

  • 设置自定义的maven仓库
  • 再maven目录下新建repository文件夹
  • 找到maven/conf文件下的配置文件setting.xml
  • 设置自定义的仓库地址


<localRepository>D:\maven\repository</localRepository>
  • 镜像下载地址配置
  <mirrors>
  
    <mirror>
        <id>aliyunmaven</id>
        <mirrorOf>*</mirrorOf>
        <name>阿里云公共仓库</name>
        <url>https://maven.aliyun.com/repository/public</url>
    </mirror>
        
    <!-- 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>http://my.repository.com/repo/path</url>
    </mirror>
     -->
  </mirrors>
  • JDK默认配置
<profiles>  
    <profile>
        <id>jdk18</id>
        <activation>
            <jdk>1.8</jdk>
            <activeByDefault>true</activeByDefault>
        </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>
</profiles> 

3 IDEA的相关配置

  • 新建一个maven工程


    步骤一
  • 设置配置文件路径和仓库路径


    image.png
  • 创建成功


    image.png

相关文章

网友评论

      本文标题:解决IDEA中创建maven工程相关问题

      本文链接:https://www.haomeiwen.com/subject/iuuvphtx.html