详见:http://maven.apache.org/general.html
不错的教程:
http://crunchify.com/how-to-create-a-war-file-from-eclipse-using-maven-plugin-apache-maven-war-plugin-usage/
调试模式: --debug
指定为UTF-8编码
<properties>
<spring.version>3.2.7.RELEASE</spring.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
跳过测试
-DskipTests=true
force update
http://stackoverflow.com/questions/4701532/force-maven-update
mvn clean install -U
-U seems to force update of all dependencies. If you want to update a single dependency without clean or -U you could just remove it from your local repo and then build. The example below if for updating slf4j-api 1.7.1-SNAPSHOT:
rm -rf ~/.m2/repository/org/slf4j/slf4j-api/1.7.1-SNAPSHOT
mvn compile
查看maven的安装位置
我是在mac上使用`brew install maven`命令安装的mvn, 使用如下命令
`mvn -X`
从输出内容的前几行可以得到安装位置, 配合head
➜ ~ $ mvn -X|head
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T19:57:37+08:00)
Maven home: /usr/local/Cellar/maven/3.3.3/libexec
Java version: 1.8.0_91, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.11.5", arch: "x86_64", family: "mac"
查看使用了哪个settings.xml
执行命令`mvn help:effective-settings`
Mirros备份
位置:/usr/local/Cellar/maven/3.3.3/libexec/conf/settings.xml
<mirrors>
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
|
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
-->
<!-- <mirror>
<id>ibiblio</id>
<mirrorOf>central</mirrorOf>
<name>ibiblio Mirror of http://repo1.maven.org/maven2/</name>
<url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>
</mirror> -->
<!-- <mirror>
<id>jboss-public-repository-group</id>
<mirrorOf>central</mirrorOf>
<name>JBoss Public Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public</url>
</mirror> -->
<mirror>
<id>repo2</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://repo2.maven.org/maven2/</url>
</mirror>
<mirror>
<id>ui</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://uk.maven.org/maven2/</url>
</mirror>
<mirror>
<id>nexus-osc</id>
<mirrorOf>*</mirrorOf>
<name>Nexus osc</name>
<url>http://maven.oschina.net/content/groups/public/</url>
</mirror>
</mirrors>
## 上面都弱爆了, 阿里镜像才是最快的!!!
cp /usr/local/Cellar/maven/3.3.9/libexec/conf/settings.xml ~/.m2/settings.xml (mac)
cp /etc/maven/settings.xml ~/.m2 (ubuntu16.04)
加入如下mirror
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>