环境
问题:升级到Java9后,MacOS shell环境中使用mvn 打包失败
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ platform ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 76 source files to XXX/target/classes
解决
- 检查mvn 默认的Java home 为1.9
➜ ~ mvn -v
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-04T03:39:06+08:00)
Maven home: /usr/local/Cellar/maven/3.5.0/libexec
Java version: 9, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home
Default locale: zh_CN, platform encoding: UTF-8
OS name: "mac os x", version: "10.13", arch: "x86_64", family: "mac"
- 在 ~ 用户路径下(
cd
可以直接进入 ),添加文件 touch .mavenrc
➜ ~ echo -n "JAVA_HOME=`/usr/libexec/java_home -v 1.8`" > ~/.mavenrc
参考