gpt4 book ai didi

java - 正确设置 Maven 3

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:11:18 25 4
gpt4 key购买 nike

我应该如何正确设置 Maven 3?

我的环境:

  • Linux 16;
  • Java 1.7.0_22
  • maven 3.0.4

我的 .bash_profile

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin:$JAVA_HOME/bin:$M2_HOME/bin
export PATH

JAVA_HOME=/usr/java/jdk1.7.0_02
export JAVA_HOME

M2_HOME=/home/ic/apache-maven-3.0.4
export M2_HOME

当我输入java -version时,系统会显示

java version "1.7.0_02"
Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
Java HotSpot(TM) Client VM (build 22.0-b10, mixed mode, sharing)

但是当我输入 mvn -v 时,它会显示:

bash: mvn: command not found...

我应该怎么做才能正确设置 Maven 3?

提前致谢!

最佳答案

顺序很重要!

JAVA_HOME=/usr/java/jdk1.7.0_02
export JAVA_HOME

M2_HOME=/home/ic/apache-maven-3.0.4
export M2_HOME

# after the variables are assigned!!!
PATH=$PATH:$HOME/.local/bin:$HOME/bin:$JAVA_HOME/bin:$M2_HOME/bin
export PATH

关于java - 正确设置 Maven 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9134712/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com