Mac本配置两个jdk,给maven指定jdk

问题现象:mac本运行maven package时报错

INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ gatewayinterfacemodel ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 231 source files to /Users/zhaoxj/WorkspacesIdea/gatewayInterfaceModel/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] javac: ��Ч�ı�־�� -parameters
�÷�: javac <options> <source files>
-help �����г����ܵ�ѡ��

[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.740 s
[INFO] Finished at: 2020-12-16T17:42:02+08:00
[INFO] Final Memory: 20M/228M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project gatewayinterfacemodel: Compilation failure
[ERROR] javac: ��Ч�ı�־�� -parameters
[ERROR] �÷�: javac <options> <source files>
[ERROR] -help �����г����ܵ�ѡ��
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Process finished with exit code 1

配置了两个jdk,使用maven时,要给maven指定jdk,就要在vim ~/.mavenrc中配置:export JAVA_HOME=$(/usr/libexec/java_home)

 

配置jdk和maven

vim ~/.bash_profile

export JAVA_6_HOME=/Library/Java/JavaVirtualMachines/1.6.0_65-b14-462.jdk/Contents/Home
export JAVA_8_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contets/Home
export JAVA_HOME=$JAVA_8_HOME

alias jdk6="export JAVA_HOME=$JAVA_6_HOME"
alias jdk8="export JAVA_HOME=$JAVA_8_HOME"

export MAVEN_HOME=/Users/zhaoxj/ProgramFiles/maven/apache-maven-3.2.5

export PATH=$PATH:$MAVEN_HOME/bin

source ~/.bash_profile

vim ~/.mavenrc

export JAVA_HOME=$(/usr/libexec/java_home)

最好重启机器

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值