温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

如何使用maven setting.xml

发布时间:2021-10-11 11:38:13 来源:亿速云 阅读:112 作者:iii 栏目:编程语言

这篇文章主要介绍“如何使用maven setting.xml”,在日常操作中,相信很多人在如何使用maven setting.xml问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”如何使用maven setting.xml”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

<?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">  
  
    <!-- 默认的值是${user.home}/.m2/repository -->  
    <!--<localRepository>C:\Users\Administrator\.m2\repository</localRepository> -->   
  
    <!-- 如果Maven要试图与用户交互来得到输入就设置为true,否则就设置为false,默认为true。 -->  
    <interactiveMode>true</interactiveMode>    
    <!-- 如果Maven使用${user.home}/.m2/plugin-registry.xml来管理plugin的版本,就设置为true,默认为false。 -->  
    <usePluginRegistry>false</usePluginRegistry>  
  
    <!-- 如果构建系统要在离线模式下工作,设置为true,默认为false。 如果构建服务器因为网络故障或者安全问题不能与远程仓库相连,那么这个设置是非常有用的。 -->  
    <offline>false</offline>    
    <mirrors>  
        <mirror>  
            <id>company name</id>  
            <mirrorOf>central</mirrorOf>  
            <name>Nexus company name</name>  
            <url>http://nexus.devops.sf-pharma.com/repository/maven-public/</url>  
        </mirror>  
    </mirrors>
	<!--此处设置的用户名和密码都是nexus的登陆配置-->
	 <servers>
		 <server>
		  <id>maven-releases</id>  <!--对应pom.xml的id=releases的仓库-->
		  <username>cicd_user</username>
		  <password>cicd_xxx_devops</password>
		</server>
		 <server>
		  <id>maven-snapshot</id> <!--对应pom.xml中id=snapshots的仓库-->
		  <username>cicd_user</username>
		  <password>cicd_xxx_devops</password>
		</server>
	  </servers>    
    <!-- settings.xml中的profile是pom.xml中的profile的简洁形式。 它包含了激活(activation),仓库(repositories),插件仓库(pluginRepositories)和属性(properties)元素。   
        profile元素仅包含这四个元素是因为他们涉及到整个的构建系统,而不是个别的POM配置。 如果settings中的profile被激活,那么它的值将重载POM或者profiles.xml中的任何相等ID的profiles。 -->  
    <profiles>  
        <profile>  
            <id>default</id>  
            <activation>  
                <activeByDefault>true</activeByDefault>  
                <jdk>1.8</jdk>  
            </activation>  
            <repositories>  
                <repository>  
                    <id>maven-releases</id>  
                    <name>Maven Releases</name>  
                    <url>http://nexus.devops.xxx.com/repository/maven-releases/</url>  
                    <releases>  
                        <enabled>true</enabled>  
                    </releases>  
                    <snapshots>  
                        <enabled>false</enabled>  
                    </snapshots>  
                    <layout>default</layout>  
                </repository>  
                <repository>  
                    <id>maven-snapshot</id>  
                    <name>Maven Snapshots</name>  
                    <url>http://nexus.devops.xxx.com/repository/maven-snapshots/</url>  
                    <releases>  
                        <enabled>false</enabled>  
                    </releases>  
                    <snapshots>  
                        <enabled>true</enabled>  
                    </snapshots>  
                    <layout>default</layout>  
                </repository>  
            </repositories>  
        </profile>  
    </profiles>  
    <!-- activations是profile的关键,就像POM中的profiles,profile的能力在于它在特定情况下可以修改一些值。   
        而这些情况是通过activation来指定的。 -->  
    <!-- <activeProfiles/> -->    
</settings>

到此,关于“如何使用maven setting.xml”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注亿速云网站,小编会继续努力为大家带来更多实用的文章!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI