maven 配置nexus私服(普通成员只需获取不需发布)

1、本地maven的settings.xml配置项

  1. localRepository: 配置本地存储库的位置

  2. interactiveMode: 是否与用户开启交互模式,默认为 true

  3. offline: 离线模式,默认为 false

  4. pluginGroups: 比如org.eclipse.jetty,默认有org.apache.maven.plugins and org.codehaus.mojo。

  5. servers:配置私服的用户名和密码

  6. mirrors: mirror相当于一个拦截器,它会拦截maven对remote repository的相关请求,把请求里的remote
    repository地址,重定向到mirror里配置的地址。

  7. proxies: 代理配置

  8. profiles: 配置环境

  9. activeProfiles: 配置默认激活的环境

2、本地maven的完整配置

<?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>本地仓库地址</localRepository>
  
    <pluginGroups>
		<pluginGroup>com.spotify</pluginGroup>
    </pluginGroups>

  <!-- proxies
   | This is a list of proxies which can be used on this machine to connect to the network.
   | Unless otherwise specified (by system property or command-line switch), the first proxy
   | specification in this list marked as active will be used.
   |-->
  <proxies>
   
  </proxies>

  <servers>
	<!--maven私服地址搭建-->
    <server>
        <id>maven-public</id>
        <username>私服的用户名</username>
        <password>私服的密码</password>
    </server>
     <server>
        <id>maven-releases</id>
       <username>私服的用户名</username>
        <password>私服的密码</password>
    </server>
     <server>
        <id>maven-snapshots</id>
        <username>私服的用户名</username>
        <password>私服的密码</password>
    </server>
  </servers>




  <mirrors>
	<mirror>
      <id>nexus</id>
      <name>nexus</name>
      <mirrorOf>local</mirrorOf>
      <url>http://私服的ip:8081/repository/maven-public/</url>
    </mirror>
	
    <mirror>
      <id>alimaven</id>
      <mirrorOf>central</mirrorOf>
      <name>aliyun maven</name>
      <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
    </mirror>
  </mirrors>


  <profiles>
	<profile>
		<id>nexusmaven</id>
 
		<repositories>
			<repository>
				<id>nexus-maven</id>
				<url>http://私服ip:8081/repository/maven-public</url>
				<releases>
					<enabled>true</enabled>
					<updatePolicy>always</updatePolicy>
				</releases>
				<snapshots>
					<enabled>true</enabled>
					<updatePolicy>always</updatePolicy>
				</snapshots>
			</repository>
		</repositories>
		 
		<pluginRepositories>
			<pluginRepository>
				<id>nexus-maven</id>
				<url>http://私服ip:8081/repository/maven-public</url>
				<releases>
					<enabled>true</enabled>
					<updatePolicy>always</updatePolicy>
				</releases>
				<snapshots>
					<enabled>true</enabled>
					<updatePolicy>always</updatePolicy>
				</snapshots>
			</pluginRepository>
		</pluginRepositories>
	</profile>
	
  </profiles>
	
	<activeProfiles>
		<activeProfile>nexusmaven</activeProfile>
	</activeProfiles>

</settings>

3、idea项目中只需引入:

 <!-- 代码库 ,配置后相当于从国内仓库拉取代码-->
    <repositories>
      

        <repository>
            <id>maven-public</id>
            <name>maven-public</name>
            <url>http://私服ip:8081/repository/maven-public/</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>

注意:

其中 id 要和你的仓库名称一致,url 就是私服的仓库地址,就是type 为 group 的那个,它组合了一个 proxy 类型的和两个 hosted 类型的仓库。设置 snapshots 的 enabled 为ture,表示允许下载 snapshots 版本的包。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值