Icarus answered a very similar question for me. Its not using "yum", but should still work for your purposes. Try,
Copywget http://mirror.olnevhost.net/pub/apache/maven/maven-3/3.0.5/binaries/apache-maven-3.0.5-bin.tar.gz
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 wget command from the dir you want to extract maven too.
run the following to extract the tar,
Copy
tar xvf apache-maven-3.0.5-bin.tar.gzmove maven to /usr/local/apache-maven
Copy
mv apache-maven-3.0.5 /usr/local/apache-mavenNext add the env variables to your ~/.bashrc file
Copy
export M2_HOME=/usr/local/apache-maven export M2=$M2_HOME/bin export PATH=PATH
Execute these commands
source ~/.bashrc
6:. Verify everything is working with the following command
Copy mvn -version
Answer from OrwellHindenberg on Stack OverflowIcarus answered a very similar question for me. Its not using "yum", but should still work for your purposes. Try,
Copywget http://mirror.olnevhost.net/pub/apache/maven/maven-3/3.0.5/binaries/apache-maven-3.0.5-bin.tar.gz
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 wget command from the dir you want to extract maven too.
run the following to extract the tar,
Copy
tar xvf apache-maven-3.0.5-bin.tar.gzmove maven to /usr/local/apache-maven
Copy
mv apache-maven-3.0.5 /usr/local/apache-mavenNext add the env variables to your ~/.bashrc file
Copy
export M2_HOME=/usr/local/apache-maven export M2=$M2_HOME/bin export PATH=PATH
Execute these commands
source ~/.bashrc
6:. Verify everything is working with the following command
Copy mvn -version
You can add maven to the yum libraries like this:
Copywget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo
Now you can install maven like this:
Copyyum install apache-maven
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:
Copyalternatives --config java
alternatives --config javac
and choose the correct version.