Try:
试一试:
sudo apt-get install maven
If it works for you ignore the rest of this post.
如果它对您有效,请忽略本文的其余部分。
Intro
I started setting up my Ubuntu 12.10 on April 2013 and the normal sudo apt-get install maven
was not working for maven 3 back then.
我在2013年4月开始安装我的Ubuntu 12.10,那时正常的sudo apt-get安装maven没有工作。
The manual installation in this post is useful if you like to dig in deeper to your ubuntu kernel in regards with apt-get and where it finds the list of applications that are available for installation on Ubuntu. It can also be potentially useful for more recent releases of Ubuntu like Ubuntu 15.04, etc. if you face the same problem as I did back then with Ubuntu 12.10.
如果您想深入了解关于apt-get的ubuntu内核,以及它找到ubuntu上可用的应用程序列表,那么本文中的手动安装非常有用。如果你遇到的问题和我之前在Ubuntu 12.10上遇到的一样,那么它也可能对Ubuntu的最新版本有用。
Automatic Installation via apt-get:
Checkout the manual installation if your current ubuntu can not install maven via common 'apt-get install maven'.
如果您当前的ubuntu不能通过常见的“apt-get install maven”安装maven,请检查手动安装。
sudo apt-get updatesudo apt-get install maven
Make sure to remove maven 2 if your ubuntu is not fresh or if you were using maven 2 before:
如果你的ubuntu不新鲜,或者你以前使用过maven 2,请确保删除maven 2:
sudo apt-get remove maven2
Manual Installation via apt-get by adding maven 3 repository (Ubuntu 14.04 check out update 1):
This can be useful if your ubuntu apt-get repositories list is not up to date.
如果您的ubuntu apt-get存储库列表没有更新,这将非常有用。
Maven 3 was required to set up the system and as it turns out most of the documents out there are referring to how to install Maven to Ubuntu version 12.04 or before. Best document I found was:
Maven 3被要求建立这个系统,而且事实证明,大多数文档都提到了如何将Maven安装到Ubuntu 12.04版本或之前的版本。我找到的最好的文件是:
killertilapia的博客
The whole process I came up with is as follows:
我想到的整个过程如下:
sudo -H gedit /etc/apt/sources.list
- sudo - h中/etc/apt/sources.list
-
Add the following line the
sources.list
file:在源代码中添加以下一行。文件列表:
deb http://ppa.launchpad.net/natecarlson/maven3/ubuntu precise main
deb http://ppa.launchpad.net/natecarlson/maven3/ubuntu精确的主要
deb-src http://ppa.launchpad.net/natecarlson/maven3/ubuntu precise main
deb-src http://ppa.launchpad.net/natecarlson/maven3/ubuntu精确的主要
-
sudo apt-get update && sudo apt-get install maven3
sudo apt-get update & sudo apt-get install maven3
sudo ln -s /usr/share/maven3/bin/mvn /usr/bin/mvn
- sudo ln -s /usr/share/maven3/bin/mvn /usr/bin/mvn
Caution 1: command "sudo apt-add-repository ppa:natecarlson/maven3" did not work on my Ubuntu and had to run
sudo apt-add-repository -rm ppa:natecarlson/maven3
to get my apt-get to work again.警告1:命令“sudo ap -add repository ppa:natecarlson/maven3”没有在我的Ubuntu上运行,并且必须运行sudo apt-add-repository -rm ppa:natecarlson/maven3,以获得我的ap -get工作。
Caution 2: thanks to David, you need to remove your existing symbolic link to previous versions of maven before running step 4.
注意2:感谢David,在运行步骤4之前,您需要删除现有的指向maven的符号链接。
OS X Installation
I decided to add OS X installation in case you use multiple environments for your dev: See the source * thread for more details.
我决定添加OS X安装,以防您为您的dev使用多个环境:查看源*线程以获得更多细节。
Install Homebrew that is the equavalent of apt-get
, then install Maven using:
安装与apt-get相同的Homebrew,然后使用:
brew install maven
Update 1: Installation for Ubunutu 14.04
Haven't tried this myself but I am confident this should work without security warnings:
我自己还没有尝试过这个,但是我相信在没有安全警告的情况下,这个方法会奏效:
sudo apt-get purge maven maven2 maven3sudo apt-add-repository ppa:andrei-pozolotin/maven3sudo apt-get updatesudo apt-get install maven3
Note: source here, many thanks and +1s to @rendybjunior, @Dominic_Bartl, and @FunThomas424242
注意:这里的源,很多感谢和+1到@rendybjunior, @Dominic_Bartl,和@FunThomas424242。
2 个解决方案
#2
10
It's best to use miske's answer.
最好使用miske的答案。
Properly installing natecarlson's repository
If you really want to use natecarlson's repository, the instructions just below can do any of the following:
如果您真的想使用natecarlson的存储库,下面的说明可以执行以下任何操作:
- set it up from scratch
- 从头开始
- repair it if
apt-get update
gives a404
error afteradd-apt-repository
- 如果apt-get更新在add-apt-repository之后出现404错误,则进行修复
- repair it if
apt-get update
gives aNO_PUBKEY
error after manually adding it to/etc/apt/sources.list
- 如果apt-get更新在手动添加到/etc/apt/sources.list之后出现NO_PUBKEY错误,请修复它
Open a terminal and run the following:
打开终端,运行以下操作:
sudo -i
Enter your password if necessary, then paste the following into the terminal:
如有需要,请输入密码,然后将以下内容粘贴到终端:
export GOOD_RELEASE='precise'export BAD_RELEASE="`lsb_release -cs`"cd /etc/aptsed -i '/natecarlson\/maven3/d' sources.listcd sources.list.drm -f natecarlson-maven3-*.list*apt-add-repository -y ppa:natecarlson/maven3mv natecarlson-maven3-${BAD_RELEASE}.list natecarlson-maven3-${GOOD_RELEASE}.listsed -i "s/${BAD_RELEASE}/${GOOD_RELEASE}/" natecarlson-maven3-${GOOD_RELEASE}.listapt-get updateexitecho Done!
Removing natecarlson's repository
If you installed natecarlson's repository (either using add-apt-repository
or manually added to /etc/apt/sources.list
) and you don't want it anymore, open a terminal and run the following:
如果您安装了natecarlson的存储库(使用附加组件存储库或手工添加到/etc/apt/sources.list),并且您不再需要它,那么打开一个终端并运行以下命令:
sudo -i
Enter your password if necessary, then paste the following into the terminal:
如有需要,请输入密码,然后将以下内容粘贴到终端:
cd /etc/aptsed -i '/natecarlson\/maven3/d' sources.listcd sources.list.drm -f natecarlson-maven3-*.list*apt-get updateexitecho Done!
#1
#2
10
It's best to use miske's answer.
最好使用miske的答案。
Properly installing natecarlson's repository
If you really want to use natecarlson's repository, the instructions just below can do any of the following:
如果您真的想使用natecarlson的存储库,下面的说明可以执行以下任何操作:
- set it up from scratch
- 从头开始
- repair it if
apt-get update
gives a404
error afteradd-apt-repository
- 如果apt-get更新在add-apt-repository之后出现404错误,则进行修复
- repair it if
apt-get update
gives aNO_PUBKEY
error after manually adding it to/etc/apt/sources.list
- 如果apt-get更新在手动添加到/etc/apt/sources.list之后出现NO_PUBKEY错误,请修复它
Open a terminal and run the following:
打开终端,运行以下操作:
sudo -i
Enter your password if necessary, then paste the following into the terminal:
如有需要,请输入密码,然后将以下内容粘贴到终端:
export GOOD_RELEASE='precise'export BAD_RELEASE="`lsb_release -cs`"cd /etc/aptsed -i '/natecarlson\/maven3/d' sources.listcd sources.list.drm -f natecarlson-maven3-*.list*apt-add-repository -y ppa:natecarlson/maven3mv natecarlson-maven3-${BAD_RELEASE}.list natecarlson-maven3-${GOOD_RELEASE}.listsed -i "s/${BAD_RELEASE}/${GOOD_RELEASE}/" natecarlson-maven3-${GOOD_RELEASE}.listapt-get updateexitecho Done!
Removing natecarlson's repository
If you installed natecarlson's repository (either using add-apt-repository
or manually added to /etc/apt/sources.list
) and you don't want it anymore, open a terminal and run the following:
如果您安装了natecarlson的存储库(使用附加组件存储库或手工添加到/etc/apt/sources.list),并且您不再需要它,那么打开一个终端并运行以下命令:
sudo -i
Enter your password if necessary, then paste the following into the terminal:
如有需要,请输入密码,然后将以下内容粘贴到终端:
cd /etc/aptsed -i '/natecarlson\/maven3/d' sources.listcd sources.list.drm -f natecarlson-maven3-*.list*apt-get updateexitecho Done!