类别 全部 - repositories - dependencies

作者:Israel Barbosa 9 年以前

373

Maven

Configuring Maven involves setting up various elements to ensure smooth functioning, including managing dependencies and using repositories. A critical component is the settings.xml file, which can be customized to address specific needs such as proxy configurations and server interactions.

Maven

Maven

Maven Dependency Management

dependendy identification
Using repositories

2. Setting up Maven

Settings.xml
8. activeProfile

Allows you to specify a default profile to be active for Maven to use.

7. profiles

Allow you to group certain configuration elements, such as repositories and pluginRepositories.

6. proxies

Contains the HTTP proxy information to connect to the internet.

setting up a proxy

As we will discuss in detail in Chapter 3, Maven requires an Internet connection to
download plug-ins and dependencies. Some companies employ HTTP proxies to
restrict access to the Internet. In those scenarios, running Maven will result in Unable to
download artifact errors. To address this, edit the settings.xml file and add the proxy
information specific to your company. A sample configuration is shown in Listing 2-2.

<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">
<proxies>
<proxy>
<id>companyProxy</id>
<active>true</active>
<protocol>http</protocol>
<host>proxy.company.com</host>
<port>8080</port>
<username>proxyusername</username>
<password>proxypassword</password>
<nonProxyHosts />
</proxy>
</proxies>
</settings>

5. mirrors

Allow you to specify alternate locations for your repositories.

4. servers

Maven can interact with a variety of servers, such as Apache subversion (SVN), build servers, and remote repository servers. This element allows you specify security credentials such as the username and password, which you need to connect to those servers.

3. offline

When set to true, this configuration instructs Maven to operate in offiline mode. The default is true.

2. interactiveMode

As the name suggest, when this value is set to true, the default value, Maven interacts with the user for input.

1. localRepository

Maven stores copies of plug-ins and dependencies locally in C:\Users\israelfap\.m2\repository folder.
This element can be used to change the path of the local repository.
For exemple, <localRepository>c:\mavenrepo</localRepository
will change the repository location to the mavenrepo folder.