Maven - Java

Idea 全局配置 Maven

在 Close Project 之后的初始界面 进入 Settings 配置,此时的配置就是全局配置

环境变量

MAVEN_HOME

Path %MAVEN_HOME%\bin

conf.xml 配置

本地仓库:

1
<localRepository>D:\aa\AppData\maven</localRepository>

阿里云镜像:

1
2
3
4
5
6
<mirror>  
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>

依赖

<dependency>

依赖配置

1
2
3
4
5
6
7
8
9
<project>
<dependencies>

<dependency>
// ...
</dependency>

</dependencies>
</project>

嵌套依赖

<dependency> 可以引用另一个 模块/项目 ,形成嵌套依赖

范围 scope

1
2
3
4
5
6
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>3.2.1.RELEASE</version>
<scope>test</scope>
</dependency>

各种取值:

scope取值 有效范围(compile, runtime, test) 依赖传递 例子
compile all spring-core
provided compile, test servlet-api
runtime runtime, test JDBC驱动
test test JUnit
system compile, test

Maven之scope详解 - satire - 博客园

重要的生命周期