Linux Maven安装

1、下载

官网:http://maven.apache.org/download.cgi
在这里插入图片描述

2、解压
tar zxvf apache-maven-3.6.1-bin.tar.gz -C /opt/

解压之后的目录为 : /opt/apache-maven-3.6.1/

3、环境变量
vim /etc/profile

在打开的文件最后面添加以下信息

export M2_HOME=/opt/apache-maven-3.6.1
export PATH=$PATH:$M2_HOME/bin

让配置生效

source /etc/profile

验证是否安装完成

mvn -version

在这里插入图片描述
至此,安装成功!

4、配置文件详解
<?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>C:\Users\asus\.m2\repository</localRepository>
    
	<pluginGroups>
        <!-- pluginGroup
		| Specifies a further group identifier to use for plugin lookup.
		<pluginGroup>com.your.plugins</pluginGroup>
		-->
    </pluginGroups>
    
	<proxies>
        <!-- proxy
		| Specification for one proxy, to be used in connecting to the network.
		|
		<proxy><id>optional</id><active>true</active><protocol>http</protocol><username>proxyuser</username><password>proxypass</password><host>proxy.host.net</host><port>80</port><nonProxyHosts>local.net|some.host.com</nonProxyHosts></proxy>
		-->
    </proxies>
    
	<!-- 仓库服务配置 -->
    <servers>
        <!-- 私服的验证信息 -->
        <server>
            <id>releases</id>
            <username>admin</username>
            <password>admin123</password>
        </server>
        <server>
            <id>snapshots</id>
            <username>admin</username>
            <password>admin123</password>
        </server>
    </servers>
    
	<!-- 镜像配置 -->
	<mirrors>
        <!-- 下面是我们搭的私服仓库。maven对全部仓库的访问全部拦截到私服的public仓库中去,如果私服关闭,那么就不能访问中央工厂了 -->
        <mirror>
            <id>nexus</id>
            <mirrorOf>*</mirrorOf>
            <url>http://nexus.xbdream.cn:8000/content/groups/public/</url>
        </mirror>
        <!-- 下面是阿里云私服仓库 -->
        <!-- <mirror>
            <id>nexus-aliyun</id>
            <mirrorOf>*</mirrorOf>
            <name>Nexus aliyun</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
        </mirror> -->
    </mirrors>
    
    <!-- 一些自定义配置 -->
	<profiles>
        <profile>
            <id>myProfile</id>
            <!-- 激活这个配置 -->
            <activation>
                <activeByDefault>true</activeByDefault>
				<jdk>1.8</jdk>
            </activation>

			<!-- 全局属性配置,让所有 maven 项目新建时默认都是 java8、UTF-8 -->
            <properties>
                <jdk.version>1.8</jdk.version>
                <maven.compiler.source>1.8</maven.compiler.source>
                <maven.compiler.target>1.8</maven.compiler.target>
                <encoding>UTF-8</encoding>
            </properties>
            
			<!--依赖仓库的一些配置,其主要作用是用来覆写 nexus 仓库的一些策略-->
            <repositories>
                <repository>
                    <id>nexus</id>
                    <name>Nexus</name>
                    <url>http://nexus.xbdream.cn:8000/content/groups/public/</url>
                    <!-- 允许下载 releases 类型依赖 -->
                    <releases><enabled>true</enabled></releases>
                    <!-- 允许下载 snapshots 类型依赖 -->
                    <snapshots><enabled>true</enabled></snapshots>
                </repository>
            </repositories>
            
			<!--插件仓库配置-->
            <pluginRepositories>
                <pluginRepository>
                    <id>nexusPluginRepositories</id>
                    <url>http://nexus.xbdream.cn:8000/content/groups/public/</url>
                    <!-- 允许下载 releases 类型依赖 -->
                    <releases><enabled>true</enabled></releases>
                    <!-- 允许下载 snapshots 类型依赖 -->
                    <snapshots><enabled>true</enabled></snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>

</settings>

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值