如何使用 Yum 安装 Maven?
我试图不了解太多有关 yum 或 maven 的知识。我继承了这段代码,并且我不想在这个环境中花费更多的时间。
我有百胜。我的安装“有”(“也附加了”?“知道”?)两个存储库:Amazon 和 JPackage,我认为这是一种标准。 (实际上,每个存储库都包含两个子存储库,但我不认为这会导致问题。)
当我要求 yum 安装 maven2 时,它拒绝了,说它从未听说过 maven2。
当我要求 yum 安装 maven2 时忽略 Amazon,它确实这样做了,但它安装了相当旧的 Maven 2.0.9。我实际的 pom.xml 需要更高的版本。
当我 Google 搜索 Maven 存储库时,我得到的是 Maven 可以用来构建其他东西的存储库,而不是 Yum 可以用来安装 Maven 的存储库。 (我确实找到了一个包含让 Maven 构建 Yum 的东西的存储库。我认为 Google 在这一点上正在嘲笑我。)
因此,我需要的只是存储库文件,它指向包含我的任何内容的存储库。需要安装Maven 2.2.1。
如果没有这些节省劳力的设备,我可能可以完成一些工作。
I'm trying not to learn much about either yum or maven. I've inherited this code and I don't want to spend more time than I have to in this environment.
I've got yum. My installation "has" ("is attached too"? "knows about"?) two repos: the Amazon one and JPackage, which I understand is something of a standard. (Actually, each of those repositories consists of two sub-repositories, but I don't think that's causing the problem.)
When I asked yum to install maven2, it declined, saying it had never heard of maven2.
When I asked yum to install maven2 ignoring Amazon, it does so, but it installs Maven 2.0.9, which is fairly old. The actual pom.xml I have requires a higher version.
When I Google for Maven repositories I get repositories that Maven can use to build other things, not repositories that Yum can use to install Maven. (I did find a repository containing thing that let Maven build Yum. I think Google is mocking me at this point.)
So, all I need is the repo file that points to a repo that contains whatever I need to install Maven 2.2.1.
If it weren't for all these labor-saving devices, I could probably get some work done.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
我最近刚刚了解到一个名为 fpm 的便捷打包工具。偶然发现这个问题,我想我可以尝试一下。事实证明,在阅读@OrwellHindenberg 的回答后,使用 fpm 将 maven 打包成 RPM 是很容易的。
创建项目目录并布局包的目录结构
创建一个文件,我们将安装到
/etc/profile.d/maven.sh
,我们将其存储在新创建的etc/profile.d目录为maven.sh,包含以下内容下载并解压最新的 Maven 中 最后在opt 目录中
,构建 RPM
现在你可以通过 rpm
和 viola
安装 Maven,虽然不完全是yum,但离家更近了;)
I've just learned of a handy packaging tool called fpm recently. Stumbling upon this question I thought I might give it a try. Turns out, after reading @OrwellHindenberg's answer, it's easy to package maven into an RPM with fpm.
create a project directory and layout the directory structure of the package
create a file that we'll install to
/etc/profile.d/maven.sh
, we'll store this under the newly created etc/profile.d directory as maven.sh, with the following contentsdownload and unpack the latest maven in the opt directory
finally, build the RPM
Now you can install maven through rpm
and viola
not quite yum but closer to home ;)
需要用yum安装吗?还有很多其他可能性:
Do you need to install it with yum? There's plenty other possibilities:
这就是我在 Amazon/AWS EMR v5 上经历的事情。 (改编自之前的答案),拥有 Maven 和 Java8。
pick Java8
pick Java8
现在,如果你运行:
你应该得到:
This is what I went through on Amazon/AWS EMR v5. (Adapted from the previous answers), to have Maven and Java8.
pick Java8
pick Java8
Now, if you run:
You should get:
自 2014 年中期以来,Maven 已针对 Fedora 进行了打包,因此现在非常简单。只需输入
Now test the Installation,只需在随机目录中运行 maven
就会失败,因为您没有指定目标,例如
mvn package
Maven is packaged for Fedora since mid 2014, so it is now pretty easy. Just type
Now test the installation, just run maven in a random directory
And it will fail, because you did not specify a goal, e.g.
mvn package
不仅仅是
mvn
,对于任何 util,您都可以通过给出yum whatprovides {command_name}
来了解自己Not just
mvn
, for any util, you can find out yourself by givingyum whatprovides {command_name}
伊卡洛斯为我回答了一个非常相似的问题。它不使用“yum”,但仍然应该适合您的目的。尝试一下,
基本上只需访问 maven 站点。找到你想要的maven版本。文件类型并使用上面 wget 语句的镜像。
之后的过程很简单,
运行以下命令来提取 tar,
将 maven 移动到 /usr/local/apache-maven
接下来将环境变量添加到 ~/.bashrc 文件
执行这些命令
source ~/.bashrc
6:。使用以下命令验证一切正常
Icarus answered a very similar question for me. Its not using "yum", but should still work for your purposes. Try,
basically just go to the maven site. Find the version of maven you want. The file type and use the mirror for the wget statement above.
Afterwards the process is easy
run the following to extract the tar,
move maven to /usr/local/apache-maven
Next add the env variables to your ~/.bashrc file
Execute these commands
source ~/.bashrc
6:. Verify everything is working with the following command
您可以将 maven 添加到 yum 库,如下所示:
现在您可以像这样安装 maven:
一旦完成,将安装 maven 3 并且
mvn -version
将显示哪个版本你有 - 我有 3.2.1。除了一个例外,这在 CentOS 6 上对我来说非常有效。它安装了 OpenJDK 1.6 并使其成为默认的 Java 版本,尽管我已经手动安装了 JDK 8(可能因为是我手动安装的)。要将其更改回来,请使用
alternatives
:并选择正确的版本。
You can add maven to the yum libraries like this:
Now you can install maven like this:
Once done, maven 3 will be installed and
mvn -version
will show you which version you've got - I had 3.2.1.This worked perfectly for me on CentOS 6 with one exception. It installed OpenJDK 1.6 and made it the default Java version, even though I'd already manually installed JDK 8 (possibly because I'd manually installed it). To change it back use
alternatives
:and choose the correct version.
为了将来的参考和简单起见,对于懒惰的人来说,他们不需要太多解释,只需运行并使其尽快工作:
For future reference and for simplicity sake for the lazy people out there that don't want much explanations but just run things and make it work asap:
对于 JVM 开发人员来说,这是一个 SDK 管理器,可提供您所需的所有工具。
https://sdkman.io /
安装sdkman:
安装Maven:
for JVM developer, this is a SDK manager for all the tool you need.
https://sdkman.io/
Install sdkman:
Install Maven:
对于那些正在寻找 2018 年安装 Maven 方法的人来说:
现在已经支持了。
For those of you that are looking for a way to install Maven in 2018:
is supported these days.