安装与配置
下载
wget http://apache.fayea.com/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.zip
也可以官网直接下载:maven官网
下载后解压
unzip http://apache.fayea.com/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.zip
环境配置
vim /etc/profile
在profile
中加入
export MAVEN_HOME=/root/dev/apache-maven-3.3.9
export PATH=$PATH:$MAVEN_HOME/bin
使profile
文件生效
source /etc/profile
测试
查看maven 版本
mvn -v
问题解决
1. maven打包时下载慢的解决方法
解决方法:
(1) 修改maven
安装目录下的conf
目录下的settings.xml
文件
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
(2) 将central的url修改为:http://uk.maven.org/maven2
(3) 修改pom.xml文件,directory
那里是jar包的位置
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<directory>./lib</directory>
<targetPath>WEB-INF/lib</targetPath>
<filtering>false</filtering>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
</webResources>
</configuration>
<version>2.1.1</version>
</plugin>
</plugins>
</build>