Maven3.6配置阿里下载源

win10

自定义本地仓库存储地址

1、打开配置文件:apache-maven-3.6.3 -> conf -> settings.xml

  <!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   | Default: ${
    
    user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  -->
  <!-- 自定义本地仓库存储地址 -->
 <localRepository>D:\GZRJ\apache-maven-3.6.3\repositorys</localRepository>

配置阿里仓库下载源

  <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>http://my.repository.com/repo/path</url>
    </mirror>
     -->
 <!-- 设置下载源:aliyun -->
    <mirror>
		<id>nexus-aliyun</id>
		<mirrorOf>*</mirrorOf>
		<name>Nexus aliyun</name>
		<url>http://maven.aliyun.com/nexus/content/groups/public</url>
	</mirror>
  </mirrors>
##################jdk###############
<profiles>
		<profile>
            <id>jdk-1.8</id>
            <activation>
                <activeByDefault>true</activeByDefault>
                <jdk>1.8</jdk>
            </activation>
            <properties>
                <maven.compiler.source>1.8</maven.compiler.gource>
                <maven.compiler.target>1.8</maven.compiler.target>
                <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
            </properties>
        </profile>
</profiles>

还有一步:环境配置,在里省略

linux环境

#jdk环境
export JAVA_HOME=/data/rj/jdk
export M2_HOME=/data/rj/maven363
export CLASSPATH=.:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar
export PATH=$PATH:${JAVA_HOME}/bin:${JAVA_HOME}/jre/bin:${M2_HOME}/bin

测试

root@kong:/# source /etc/profile
root@kong:/# mvn -v
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /data/rj/maven363
Java version: 1.8.0_261, vendor: Oracle Corporation, runtime: /data/rj/jdk/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "5.4.50-amd64-desktop", arch: "amd64", family: "unix"

猜你喜欢

转载自blog.csdn.net/qq_42476834/article/details/107931015