Maven学习笔记(2)Maven安装及setting.xml配置

Maven安装

  1. https://maven.apache.org/访问Maven网站
  2. 下载相对应的二进制包
  3. 配置环境变量

下载之后,解压:

tar -zxvf apache-maven-3.6.3-bin.tar.gz -C /usr/local

配置文件:

export MAVEN_HOME=/usr/local/maven
export PATH=$PATH:$MAVEN_HOME/bin

测试:
在这里插入图片描述

settings.xml配置

一般这个的配置文件用来配置相应的仓库地址,有的可以用URL进行访问,有的就不行。

大多数用到阿里云的仓库和中心仓库如下:
在这里插入图片描述
在这里插入图片描述

一定要会自己找仓库的域名,而不是从复制粘贴,否则会出现很多问题,因为有的仓库地址会变换,比如说现在很多域名都用https了,用http就连接不到仓库了(本人就出现过这样的问题)

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

	<!-- 设定的本地仓库位置 -->
  <localRepository>/home/${username}/.m2/repository</localRepository>

  <mirrors>
	   <!-- 阿里云仓库 -->
		<mirror>
		  <id>aliyunmaven</id>
		  <mirrorOf>*</mirrorOf>
		  <name>阿里云公共仓库</name>
		  <url>https://maven.aliyun.com/repository/public</url>
		</mirror>
 

		
	</mirrors>

  
<!-- jdk环境配置-->>
<profiles>
    <profile>
      <id>jdk-1.8</id>
      <activation>
        <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>
  </profiles>
</settings>

中央仓库如下:

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

	<!-- 设定的本地仓库位置 -->
  <localRepository>/home/${username}/.m2/repository</localRepository>

  <mirrors>
	   <!-- 阿里云仓库 -->
		<mirror>
		<id>mirrorId</id>
      	<mirrorOf>central</mirrorOf>
     	 <name>Human Readable Name for this Mirror.</name>
		</mirror>
 

		
	</mirrors>

  
<!-- jdk环境配置-->>
<profiles>
    <profile>
      <id>jdk-1.8</id>
      <activation>
        <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>
  </profiles>
</settings>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值