Maven ES1en. xml profile details

  • 2020-12-05 17:15:27
  • OfStack

The maven configuration file settings. xml exists in two places:

1. Installation place: ${M2_HOME}/conf/ settings.xml

2. User directory: ${user. home}/.m2/ settings. xml

The former is called a global configuration and works for all users of the operating system. The latter is called user configuration and only works for consumers of the current operating system. If both exist, their content is merged, and the user-scoped ES23en.xml overwrites the global settings.xml.

After installation of Maven, settings.xml will not be automatically generated in the user directory, only the global configuration file. If you need to create user-scoped ES33en.xml, copy settings under the installation path to the directory ${user.home}/.m2 /. Maven the default settings.xml is a template with comments and examples that you can quickly modify to meet your requirements.

Global configuration 1 Once changed, all users will be affected, and if maven is upgraded, all configuration will be cleared, so copy and back up the ${M2_HOME}/conf/ settings.xml file in advance, 1 It is not recommended to configure global ES51en.xml in general.

settings xml explanation

The specification


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

localRepository


 <!--  The path to the local warehouse. The default value is ${user.home}/.m2/repository .  -->
 <localRepository>usr/local/maven</localRepository> 

interactiveMode


 <!--Maven Whether you need to interact with the user to get input. if Maven Set to if you need to interact with the user to get input true , and vice versa false . The default is true . -->
 <interactiveMode>true</interactiveMode>

usePluginRegistry


<!--Maven Do you need to use plugin-registry.xml File to manage plug-in versions. If you need to let Maven Using the file ${user.home}/.m2/plugin-registry.xml To manage the plug-in version; set to true . The default is false . -->
 <usePluginRegistry>false</usePluginRegistry> 

offline


 <!-- said Maven Whether you need to run in offline mode. Yes if the build system needs to run in offline mode true By default, false . This configuration is used when the build server cannot connect to the remote warehouse due to network Settings or security factors 10 Useful points.  -->
 <offline>false</offline> 

pluginGroups


<!-- When the plug-in is organized Id ( groupId ) is not explicitly provided for search plug-in organization Id ( groupId ). This element contains 1 a pluginGroup A list of elements that each child element contains 1 An organization Id ( groupId ). When we use a plug-in, and do not provide organization in the command behavior Id ( groupId ), Maven The list is used. By default the list contains org.apache.maven.plugins and org.codehaus.mojo -->
 <pluginGroups>
 <!--plugin The organization of the Id ( groupId )  -->
 <pluginGroup>org.codehaus.mojo</pluginGroup>
 </pluginGroups> 

proxies


<!-- Used to configure different agents, multiple agents profiles  Can work with laptops or mobile devices: with simple Settings profile id You can easily change the entire agent configuration.  -->
 <proxies>
 <!-- The proxy element contains the information needed to configure the proxy -->
 <proxy>
  <!-- The agent only 1 The definition is used to distinguish between different proxy elements. -->
  <id>myproxy</id>
  <!-- Is the agent the active one? true Activates the agent. When we declare that 1 Group proxy, and at some point only needs to be activated 1 This element can be used when it is an agent.  -->
  <active>true</active>
  <!-- Agency agreement.   agreement :// The host name : Port, separated into discrete elements for easy configuration. -->
  <protocol>http</protocol>
  <!-- The hostname of the agent. agreement :// The host name : Port, separated into discrete elements for easy configuration.  -->
  <host>proxy.somewhere.com</host>
  <!-- The port of the agent. agreement :// The host name : Port, separated into discrete elements for easy configuration.  -->
  <port>8080</port>
  <!-- The agent's username, username, and password represent the login and password authenticated by the proxy server.  -->
  <username>proxyuser</username>
  <!-- The agent's password, username, and password represent the login and password authenticated by the proxy server.  -->
  <password>somepassword</password>
  <!-- List of hosts that should not be represented. The delimiter for this list is specified by the proxy server; The example uses a vertical line separator, and commas are also common. -->
  <nonProxyHosts>*.google.com|ibiblio.org</nonProxyHosts>
 </proxy>
 </proxies> 

servers


<!-- Configuring the server side 1 Some of the Settings. 1 Some Settings such as security certificates should not be and pom.xml1 The distribution. This type of information should exist on the build server settings.xml File. -->
 <servers>
 <!-- The server element contains the information needed to configure the server  -->
 <server>
  <!-- This is a server the id Note that the user is not logged in id ), the id with distributionManagement In the repository Elements of the id Match. -->
  <id>server001</id>
  <!-- Authentication user name. Authentication user name and authentication password represent the login name and password required for server authentication.  -->
  <username>my_login</username>
  <!-- Password authentication   . Authentication user name and authentication password represent the login name and password required for server authentication. Password encryption has been added 2.1.0 + . Please visit the password encryption page for details -->
  <password>my_password</password>
  <!-- The location of the private key used in authentication. Similar to the first two elements, the private key location and the private key password are specified 1 The path to the private key (default is ${user.home}/.ssh/id_dsa ) and, if necessary, 1 A secret language. In the future passphrase and password Elements may be extracted externally, but for now they must be in settings.xml The file is declared as plain text.  -->
  <privateKey>${usr.home}/.ssh/id_dsa</privateKey>
  <!-- The private key password used in authentication. -->
  <passphrase>some_passphrase</passphrase>
  <!-- Permissions when a file is created. If created at deployment time 1 A repository file or directory, and the permissions ( permission ). The legal values of these two elements are 1 a 3 Bit numbers, that corresponds to that unix File system permissions, such as 664 Or, 775 .  -->
  <filePermissions>664</filePermissions>
  <!-- Permissions when a directory is created.  -->
  <directoryPermissions>775</directoryPermissions>
 </server>
 </servers> 

mirrors


<!-- The download image list configured for the warehouse list. For advanced Settings, see the Mirror Settings page  -->
 <mirrors>
 <!-- A download image of the given repository.  -->
 <mirror>
  <!-- The only of this mirror 1 Identifier. id To distinguish between mirror Elements.  -->
  <id>planetmirror.com</id>
  <!-- Name of the mirror  -->
  <name>PlanetMirror Australia</name>
  <!-- The mirror image of URL . The build system prioritizes using this URL Instead of using the default server URL .  -->
  <url>http://downloads.planetmirror.com/pub/maven2</url>
  <!-- Of the server being mirrored id . For example, if we're going to set it up 1 a Maven Central warehouse ( http://repo.maven.apache.org/maven2/ ), you need to set the element to central . This has to be with the central warehouse id central completely 1 Cause. -->
  <mirrorOf>central</mirrorOf>
 </mirror>
 </mirrors> 

profiles


 <!-- A list of build configurations to adjust according to environment parameters. settings.xml In the profile The element is pom.xml In the profile A cropped version of the element. It contains the id . activation, repositories, pluginRepositories and  properties Elements. Here, profile The element contains only that 5 The child element is because it is concerned only with building the system as a whole (which it is settings.xml The role location of the file), rather than a separate project object model setting. if 1 a settings In the profile When activated, its value will override any other definition in POM Or in the profile.xml With the same id the profile .  -->
 <profiles>
 <!-- Configuration of components that are adjusted according to environmental parameters -->
 <profile>
  <!-- The configuration is unique 1 Identifier.  -->
  <id>test</id> 

Activation


 <!--  The path to the local warehouse. The default value is ${user.home}/.m2/repository .  -->
 <localRepository>usr/local/maven</localRepository> 
0

Properties


 <!--  The path to the local warehouse. The default value is ${user.home}/.m2/repository .  -->
 <localRepository>usr/local/maven</localRepository> 
1

note: If this profile is activated, then ${user.install} can be used in POM again.

Repositories


 <!--  The path to the local warehouse. The default value is ${user.home}/.m2/repository .  -->
 <localRepository>usr/local/maven</localRepository> 
2

activeProfiles


<!-- Manual activation profiles The list, according to profile The sequential definition to be applied activeProfile .   The element contains 1 group activeProfile Elements, each activeProfile All contain 1 a profile id . Any in activeProfile Defined in the profile id , regardless of the environment setting, what is the corresponding 
    profile It's going to be activated. If there's no match profile , nothing will happen. For example, env-test is 1 a activeProfile While the, pom.xml (or profile.xml ) in the corresponding id the profile It gets activated. If this is not found during the run 1 a profile . Maven As usual 1 Sample run.  -->
  <activeProfiles>
  <!-- -->
  <activeProfile>env-test</activeProfile>
  </activeProfiles>
</settings>

Related articles: