Answers:
Maven3是Ubuntu 12.04中的默认设置(精确)
Maven2是最新的11.10版本信息库。
Maven3的PPA似乎很稀缺-这是特立独行的 -尽管不是最新的可用版本。
最好的建议是保留发行版可用的稳定版本。
但是,如果您想保持最新状态,则可以直接下载代码并自行安装。
从此处下载.tar.gz文件,并按照同一网页上的安装指南进行操作
这是一个在64位Ubuntu 11.10上对我有效的maven3 PPA
sudo add-apt-repository ppa:natecarlson/maven3
sudo apt-get update && sudo apt-get install maven3
如果您已经从规范存储库中安装了maven2,则不会替换它,而是提供mvn3二进制文件。
如果您更喜欢使用名为mvn的二进制文件而不是mvn3,则可以执行以下操作:
sudo ln -s /usr/bin/mvn3 /usr/bin/mvn
问题是古老的,但黄金。我今天必须找到一个解决方案。开始了。无需使用不安全的存储库,因为Ubuntu 仓库中已包含maven3。Ubuntu 14.04 LTS上的解决方案如下:
sudo apt-get install maven
sudo update-alternatives --config mvn
使用第二个命令,要求您设置使用的版本。您可以通过选择maven2不属于其中的路径来区分正确的目录。
*0 /usr/share/maven2/bin/mvn 200 Auto-Modus
1 /usr/share/maven/bin/mvn 150 manueller Modus
2 /usr/share/maven2/bin/mvn 200 manueller Modus
就我而言,我必须选择1
使用发出的命令,mvn -v
您可以验证设置是否成功以及是否选择了正确的版本。下面有一个返回值的示例。
~$ mvn -version
Apache Maven 3.0.5
Maven home: /usr/share/maven
Java version: 1.7.0_75, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-openjdk-amd64/jre
Default locale: de_DE, platform encoding: UTF-8
OS name: "linux", version: "3.13.0-45-generic", arch: "amd64", family: "unix"
希望这对您有所帮助。
我制作了一个新脚本,该脚本不仅应安装Maven +将其添加到bin中,而且还应在将Ubuntu作为VirtualBox来宾使用时进行选择,然后尝试挂载可能包含(或可能不包含)现有的'.m2'和maven文件夹设置。
如果Maven在Windows或Unix上运行,它仍然保持不变,因此您可以在两者之间使用相同的Maven,因为这是您的VirtualBox设置...
PS。注意可以从/ usr / local / bin挂载/卸载共享文件夹的脚本的构建:)
#!/bin/bash
#Author: Yucca Nel http://thejarbar.org
#Will restart system
PATH="/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:."
export PATH
#Modify these variables as needed...
tempWork=/tmp/work
defaultStartScript=/etc/init.d/rc.local
defaultMaven=3.0.3
locBin=/usr/local/bin
mavenUsrLib=/usr/lib/maven
mkdir -p $mavenUsrLib
mkdir -p $HOME/.m2
read -p "Please [Enter] full path name of your local startup script ($defaultStartScript is the default). Please
make sure on this before providing a value by consulting documentation for your system:" locStartScript
locStartScript=${locStartScript:-$defaultStartScript}
read -p "Please [Enter] Maven Version ($defaultMaven is default):" mavenVersion
mavenVersion=${mavenVersion:-$defaultMaven}
if [ ! -f $locStartScript ]
then
echo "The file you provided could not be found. Remember to include the full path and try again. Exiting in 7 secs..."
sleep 7
exit 1
fi
mkdir -p /$tempWork
cd /$tempWork
sudo wget http://mirrors.powertech.no/www.apache.org/dist//maven/binaries/apache-maven-$mavenVersion-bin.tar.gz
tar -zxvf ./*
#Move it to a more logical location
sudo mv -f ./apache-maven-$mavenVersion $mavenUsrLib/
#If you have Maven on Windows and use VirtualBox, you can set up the maven to be a virtualbox shared folder.
#The name must match the name used below (ignore if irrelevant to you).
if [ -f /sbin/mount.vboxsf ]
then
sudo /sbin/umount $HOME/.m2
sudo /sbin/umount $mavenUsrLib
sudo /sbin/mount.vboxsf .m2 $HOME/.m2
sudo /sbin/mount.vboxsf maven $mavenUsrLib
fi
if mountpoint -q $HOME/.m2 && mountpoint -q $mavenUsrLib
then
#Add it to the start script to automate process...
sudo sed -ie '$d' $locStartScript
if ! grep "sudo /sbin/mount.vboxsf .m2 $HOME/.m2" $locStartScript
then
echo "sudo /sbin/mount.vboxsf .m2 $HOME/.m2" | sudo tee -a $locStartScript
fi
if ! grep "sudo /sbin/mount.vboxsf maven $mavenUsrLib" $locStartScript
then
echo "sudo /sbin/mount.vboxsf maven $mavenUsrLib" | sudo tee -a $locStartScript
fi
echo "exit 0" | sudo tee -a $locStartScript
sudo chmod +x $locStartScript
#Create a mount and unmount script file...
rm -rf $tempWork/*
echo '#!/bin/bash' > $tempWork/maven-mount.sh
echo "sudo /sbin/mount.vboxsf .m2 $HOME/.m2" >> $tempWork/maven-mount.sh
echo "sudo /sbin/mount.vboxsf maven $mavenUsrLib" >> $tempWork/maven-mount.sh
echo "echo 'mounted maven'" >> $tempWork/maven-mount.sh
echo "exit 0" >> $tempWork/maven-mount.sh
echo '#!/bin/bash' > $tempWork/maven-umount.sh
echo "sudo umount $HOME/.m2" >> $tempWork/netbeans-umount.sh
echo "sudo umount $mavenUsrLib" >> $tempWork/netbeans-umount.sh
echo "echo 'unmounted maven'" >> $tempWork/maven-mount.sh
echo 'exit 0' >> $tempWork/maven-umount.sh
#Script for mounting ALL VirtualBox shared solders....
#If there isn't one create one...
if [ ! -f $locBin/mount-all-from-host.sh ]
then
echo '#!/bin/bash' > $tempWork/mount-all-from-host.sh
echo "sudo /sbin/mount.vboxsf .m2 $HOME/.m2" | sudo tee -a $tempWork/mount-all-from-host.sh
echo "sudo /sbin/mount.vboxsf maven $mavenUsrLib" | sudo tee -a $tempWork/mount-all-from-host.sh
echo "exit 0" | sudo tee -a $tempWork/mount-all-from-host.sh
#Otherwise if there is one, but no mount, add one...
elif ! grep "sudo /sbin/mount.vboxsf .m2 $HOME/.m2" $locBin/mount-all-from-host.sh
then
sudo sed -ie '$d' $locBin/mount-all-from-host.sh
echo "sudo /sbin/mount.vboxsf .m2 $HOME/.m2" | sudo tee -a $locBin/mount-all-from-host.sh
echo "exit 0" | sudo tee -a $locBin/mount-all-from-host.sh
elif ! grep "sudo /sbin/mount.vboxsf maven $mavenUsrLib" $locBin/mount-all-from-host.sh
then
sudo sed -ie '$d' $locBin/mount-all-from-host.sh
echo "sudo /sbin/mount.vboxsf maven $mavenUsrLib" | sudo tee -a $locBin/mount-all-from-host.sh
echo "exit 0" | sudo tee -a $locBin/mount-all-from-host.sh
fi
#Script for unmounting ALL VirtualBox shared folders...
#If there isn't one create one...
if [ ! -f $locBin/umount-all-from-host.sh ]
then
echo '#!/bin/bash' > $tempWork/umount-all-from-host.sh
echo "sudo umount -a -t vboxsf" | sudo tee -a $tempWork/umount-all-from-host.sh
echo "echo 'unmounted all VirtualBox shared folders'" | sudo tee -a $tempWork/umount-all-from-host.sh
echo "exit 0" | sudo tee -a $tempWork/umount-all-from-host.sh
fi
sudo chmod +x $tempWork/*
sudo mv -f $tempWork/*.sh $locBin/
rm -rf $tempWork
fi
sudo ln -f -s $mavenUsrLib/apache-maven-$mavenVersion/bin/* /usr/bin/
sudo rm -rf $tempWork
sudo reboot
exit 0
这是可以解决此问题的maven3 PPA。
跟随安装:
sudo apt-get purge maven maven2 maven3
sudo add-apt-repository ppa:andrei-pozolotin/maven3
sudo apt-get update && sudo apt-get install maven3
现在您已经安装了maven3:
nazar@lelyak-desktop ~ $ mvn -version
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T14:57:37+03:00)
Maven home: /usr/share/maven3
Java version: 1.7.0_80, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.13.0-24-generic", arch: "amd64", family: "unix"
我升级了,但遇到了classnotfound错误。要解决此问题:
花了一些时间尝试各种组合之后,我发现这是因为我在环境变量中同时设置了M2_HOME和M3_HOME。一旦从环境变量中删除了M2_HOME,我可以再次恢复工作,这可能会节省一些时间时间一些。
如果您对无法确定出处的PPA(个人包裹档案)不满意,则可以选择这种方法。
从安全角度来看,如果您不知道它来自哪里,请不要安装它。
在我的链接文章中,我从apache检索了最新文件,这是一个已知且受信任的来源。您可以获得最新版本
\#识别最新版本的Maven Latest = $(curl http://www-us.apache.org/dist/maven/maven-3/ | tac | sed -ne's / [^ 0-9] * \(\([[0-9] \。\)\ {0,3 \} [0-9] \)。* / \ 1 / p'|头-1) \#下载它 wget http://www-us.apache.org/dist/maven/maven-3/$latest/binaries/apache-maven-$latest-bin.tar.gz
然后从安装
\#打开包装 须藤tar -zxf apache-maven- $ latest-bin.tar.gz -C / usr / local / \#创建一个符号链接 须藤ln -s / usr / local / apache-maven- $ latest / bin / mvn / usr / bin / mvn
如上面的链接和我的帖子中概述的