Java学习,从入门到放弃(二)Linux配置mvn

其实网上的教程很多,随便拿一个,比如:https://www.cnblogs.com/chuijingjing/p/10430649.html

但在实践过程中,发现可能需要将JAVA_HOME也加到 etc/profile中,否则提示类似 未将java放到maven中的错误,以下为profile中正确写法:

export JAVA_HOME=/usr/local/jdk1.8.0_11
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export MAVEN_HOME=/usr/local/apache-maven-3.6.1
export PATH=$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH

其中CLASSPATH可以写为:

export CLASSPATH=.:$JAVA_HOME/lib

注意以上大小写一定要正确!!!!!!最后保存profile后不要忘记 source profile



根目录$HOME下.bash_profile和 etc/profile 区别:https://www.cnblogs.com/lianghe01/p/5264551.html

简单讲就是 etc/profile 用于全局,不限用户,而.bash_profile限于用户,对于安全性要求较高的多用户合用服务器 可能使用.bash_profile更安全,一般 etc/profile没问题。

查看$HOME下的文件方式为:

cd $HOME
ls -a

**************************************************************************

查看maven 本地仓库地址:

mvn help:evaluate -Dexpression=settings.localRepository | grep -v '[INFO]'
原文地址:https://www.cnblogs.com/jying/p/11308924.html