安装包准备:
jdk-7u79-linux-x64.rpm
apache-maven-3.5.3-bin.tar.gz
安装:
rpm -ihv jdk-7u79-linux-x64.rpm
tar -xvf apache-maven-3.5.3-bin.tar.gz -C /opt
配置:
修改配置文件私服地址
vim /opt/apache-maven-3.5.3/conf/settings.xml
<mirrors>
<mirror>
<id>n****d</id>
<mirrorOf>*</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://ip:port/nexus/content/groups/public</url>
</mirror>
</mirrors>
#添加mvn命令的环境变量
export MAVEN_HOME=/opt/apache-maven-3.5.3/bin
export PATH=$PATH:$MAVEN_HOME
#查看mvn版本
mvn -v
安装完成
试用:
1.创建一个helloworld的项目
mvn archetype:generate -DgroupId=helloworld -DartifactId=helloworld
2.打包:会生成一个target目录
cd helloworld/
mvn package
3.清理打包目录target
mvn clean
4.清理打包历史并打包
mvn clean package
当mvn打包一个项目时报错 No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
解决方法:yum -y install java-devel