Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Maven settings.xml configuration details

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

First of all: the address of the search for all public jar packages in the Maven central warehouse is http://search.maven.org/

= Maven base-default central warehouse = =

When we create a simple Maven project (only need to configure the dependency in pom.xml), run mvn clean install to build the project, we do not need to download any jar manually, it all depends on the existence of the central warehouse, it will be automatically downloaded from the warehouse. The warehouse is defined in ${M2_HOME} / lib/maven-2.0.10-uber.jar. You can find the file\ org\ apache\ maven\ project\ pom-4.0.0.xml, which defines the address of the default central warehouse:

Central

Maven Repository Switchboard

Default

Http://repo1.maven.org/maven2

False

If you want to override the default address of the central repository, we will use the image here, which is also configured in setting.xml:

...

Maven-net-cn

Maven China Mirror

Http://maven.net.cn/content/groups/public/

Central

...

This means that only central repositories are mirrored. If you want to mirror all repositories, you can change it to:

*

= = Maven configuration details = =

Maven2 requires far fewer files to configure than maven1, focusing on pom.xml and settings.xml.

Let's start with the fact that settings.xml,settings.xml is the equivalent of a global configuration for maven for all projects. There are two settings.xml in maven2, one of which is located under the installation directory conf of maven2 as a global configuration. For team settings, consistent definition is key, so the settings.xml under maven2/conf serves as a common configuration file for the team. Ensure that all team members have the same configuration. Of course, for each member, special custom settings, such as user information, are required, so another settings.xml is used as a local configuration. The default location is in the ${user.dir} / .m2 / settings.xml directory (${user.dir} refers to the user directory in windows).

The basic structure of settings.xml is as follows:

/ / path to the local warehouse

/ / true if you need to get interactive input, otherwise false

/ / if you use .m2/plugin-registry.xml to manage plugin, the version is true.

/ / offline mode is true

/ / plug-in group, which contains a series of pluginGroup elements

/ / server, tomcat: deployment server, others: Mave private server

/ / Image, specify the address of the repository, then download the jar package and plug-ins from the specified image by default

/ / proxy, configure HTTP proxy for Maven

/ / Personality configuration

/ / activated personality configuration

A brief introduction to several major configuration factors:

LocalRepository: indicates the location of the local library, that is, the main jar location of maven2, which defaults to ${user.dir} / .m2 / repository. If you need to set it otherwise, change it to another path.

Offline: if you don't want to find the remote central library every time you compile, set it to true. Of course, the premise is that you have downloaded the necessary dependency packages.

Servers

The distributionManagement element in POM defines the development library. However, specific username and pwd cannot be used with pom.xml, so server information is saved through this configuration

Server001

My_login

My_password

${usr.home} / .ssh/id_dsa

Some_passphrase

six hundred and sixty four

seven hundred and seventy five

The id of id:server, which is used to match the distributionManagement library id, is important.

Username, password: username and password used to log in to this server

PrivateKey, passphrase: set private key, and passphrase

FilePermissions, directoryPermissions: access is required when a library file or directory is created. Refer to unix file licenses, such as 664 and 775

Mirrors

Represents a mirror library, specifies the image of the library, and is used to add other libraries

Planetmirror.com

PlanetMirror Australia

Http://downloads.planetmirror.com/pub/maven2

Central

Id,name: a unique flag used to distinguish between mirrors

Url: mirrored url

MirrorOf: the service id that this image points to

Proxies

This setting is mainly used for library user configurations that do not have direct access to the center.

Myproxy

True

Http

Proxy.somewhere.com

8080

Proxyuser

Somepassword

* .google.com | ibiblio.org

Id: flag of the agent

Active: whether to activate the agent

Protocol, host, port:protocol://host:port agent

Username, password: username and password

NonProxyHosts: host that does not require an agent

Profiles

Similar to profile elements in pom.xml, mainly including activation,repositories,pluginRepositories and properties elements

At the beginning of contact, it may be confusing, in fact, this is a more powerful feature in maven2. Literally, it is personality configuration.

When a profile is defined separately, it does not take effect and needs to be activated by meeting the conditions.

Repositories and pluginRepositories

Define other development libraries and plug-in development libraries. For the team, there must be their own development libraries. It can be defined by this configuration.

The following configuration defines a local development library for release distribution.

Repo-local

Internal development library

Http://192.168.0.2:8082/repo-local

True

Never

Warn

False

Default

Repo-local

Internal development library

Http://192.168.0.2:8082/repo-local

True

Never

Warn

False

Default

Releases, snapshots: the Release or snapshot of each product version (Note: the difference between release and snapshot, release is generally a more stable version, while snapshot is basically unstable, just as a snapshot)

Properties

The properties of maven is used as the placeholder value, such as the properties of ant.

Includes the following five types of values:

Env.X, which returns the current environment variable

Project.x: returns the element value defined in pom, such as project.version

Settings.x: returns the elements defined in settings.xml

Java system property: all values returned by java.lang.System.getProperties ()

X: the value set by the user

Activation

Used to activate this profile

False

1.5

Windows XP

Windows

X86

5.1.2600

MavenVersion

2.0.3

${basedir} / file2.properties

${basedir} / file1.properties

Jdk: if the specified jdk version is matched, it will be activated

Os: operating system

Property: if maven can detect the corresponding attribute

File: used to determine whether a file exists or does not

In addition to using activation to activate profile, you can also activate it through activeProfiles

Active Profiles

Represents the active profile, specified by profile id.

Profile id specified by env-test

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report