跳至主要內容

Maven 配置

小于 1 分钟

Maven 配置

1 Downloads

2 环境变量

# /etc/profile
export M2_HOME=/uar/local/apache-maven-x.y.z
export PATH=$PATH:$M2_HOME/bin

# 立即生效
$ source /etc/profile

3 配置 settings.xml 源与 localRepository

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <localRepository>D:\repository</localRepository>
  <offline>false</offline>

  <mirrors>
    <mirror>
      <id>huaweicloud</id>
      <mirrorOf>*</mirrorOf>
      <url>https://mirrors.huaweicloud.com/repository/maven/</url>
    </mirror>
  </mirrors>

  <profiles>
    <profile>
      <id>jdk-1.8</id>
      <activation>
        <activeByDefault>true</activeByDefault>
        <jdk>1.8</jdk>
      </activation>
      <properties>
        <maven.complier.source>1.8</maven.complier.source>
        <maven.complier.tatget>1.8</maven.complier.tatget>
        <maven.complier.compilerVersion>1.8</maven.complier.compilerVersion>
      </properties>
    </profile>
  </profiles>
</settings>

4 Maven 本地打包命令

# 跳过单元测试
mvn clean package -Dmaven.test.skip=true

(全文完)