正确设置 Maven 3

发布于 2025-01-02 11:42:24 字数 870 浏览 0 评论 0原文

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

我的环境:

  • Fedora 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)

会显示:

bash: mvn: command not found...

但是当我输入 mvn -v 时,它 我这样做,为了正确设置 Maven 3?

提前致谢!

How should I set up Maven 3 properly?

My environment:

  • Fedora Linux 16;
  • Java 1.7.0_22
  • Maven 3.0.4

My .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

When I type java -version, the system shows me

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)

But when I type mvn -v, it shows me:

bash: mvn: command not found...

What should I do, in order to set up Maven 3 properly?

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

傲鸠 2025-01-09 11:42:24

订购很重要!

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

Ordering is important!

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
叶落知秋 2025-01-09 11:42:24

这是 Ubuntu 中的一种配置方法。

B1:下载 Maven 并解压到任意文件夹。

EX:thong.tv 文件夹。

B2:转到文件 .bashrc,通常位于

EX 链接目录:/home/local/thong.tv。

这是一个隐藏文件,因此如果您看不到它,可以键入 Ctrl + H 来查看。
打开上面的文件,转到底部并粘贴以下内容:

MAVEN_HOME="/home/local/thong.tv/apache-maven-3.3.9"
PATH=$PATH:$MAVEN_HOME/bin
export MAVEN_HOME
export PATH

B3:检查 maven 是否存在。
打开终端类型:

mvn -version

你会看到这样的:

thong.tv@java-thongtv:~$ mvn -version Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T23:41:47+07:00)
Maven home: /home/local/SUTRIXMEDIA1/thong.tv/apache-maven-3.3.9
Java version: 1.8.0_144, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.10.0-32-generic", arch: "amd64", family: "unix"

记住:在设置Maven之前先设置jdk。

This is a way to config in Ubuntu.

B1: Download Maven and extract at any folder.

EX: thong.tv folder.

B2: Go to file .bashrc, in usual it in directory

EX link : /home/local/thong.tv.

This is a hide file so if you don't see it, you can type Ctrl + H to see.
Open above file go bottom and paste this:

MAVEN_HOME="/home/local/thong.tv/apache-maven-3.3.9"
PATH=$PATH:$MAVEN_HOME/bin
export MAVEN_HOME
export PATH

B3: Check maven exist.
Open terminal type:

mvn -version

You will see like this:

thong.tv@java-thongtv:~$ mvn -version Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T23:41:47+07:00)
Maven home: /home/local/SUTRIXMEDIA1/thong.tv/apache-maven-3.3.9
Java version: 1.8.0_144, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.10.0-32-generic", arch: "amd64", family: "unix"

Remember: set up jdk before set up Maven.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文