1、maven下载地址:https://maven.apache.org/download.cgi
下载 apache-maven-3.6.1-bin.tar.gz
2、在linux环境中创建maven目录,/usr/local/maven,将maven安装包上传至此目录中
3、配置环境变量
vi /etc/profile
将下面这两行代码拷贝到文件末尾并保存
MAVEN_HOME=/usr/local/maven/apache-maven-3.6.1
export PATH=${MAVEN_HOME}/bin:${PATH}
重载环境变量
source /etc/profile
4、查看结果
mvn –v
5、替换maven源,阿里云的源
打开maven配置文件,比如:
vim /usr/local/maven/apache-maven-3.6.1/conf/settings.xml
找到
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
6、指定下载资源位置
<localRepository>/usr/local/maven/repository</localRepository>
7、指定JDK版本
<profile>
<id>jdk-1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
8、项目打包不打包jar包
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<layout>ZIP</layout>
<includes>
<include>
<groupId>nothing</groupId>
<artifactId>nothing</artifactId>
</include>
</includes>
</configuration>
</plugin>
评论区