Neurohazard
暮雲煙月,皓首窮經;森羅萬象,如是我聞。

maven 环境配置与简易打包

wpadmin~March 17, 2019 /System Management

Contents

maven 环境配置与简易打包

maven 环境配置

https://maven.apache.org/download.cgi

Windows 环境直接下载 zip,之后把 %MVN_HOME%/bin 的目录放到系统的 Path 环境变量中。
新建 cmd ,尝试 mvn --version 验证是否添加成功。

OSX 配置 Maven 基本步骤

wget https://downloads.apache.org/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
tar -zxvf apache-maven-3.6.3-bin.tar.gz
cd apache-maven-3.6.3

修改 ~/.zshrc 文件

# Maven
export M2_HOME="/Users/blkstone/Downloads/tools/apache-maven-3.6.3"
export PATH="$PATH:$M2_HOME/bin"

检查是否安装成功

source ~/.zshrc
mvn -v

打包

测试项目
https://github.com/c0ny1/chunked-coding-converter

mvn package assembly:single -e

另外遇到一个报错
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

https://stackoverflow.com/questions/19655184/no-compiler-is-provided-in-this-environment-perhaps-you-are-running-on-a-jre-ra

解决方案是修改 pox.xml 文件,详细指定了 JDK 的具体路径。

<build>
...
    <plugins>
    ...
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <fork>true</fork>
                <executable>C:\Program Files\Java\jdk1.8.0_181\bin\javac.exe</executable>
            </configuration>
        </plugin>
    </plugins>
</build>

Leave a Reply

Your email address will not be published. Required fields are marked *