Linux installation configuration maven3.0 and setting up a Nexus

Source: Internet
Author: User
Tags gz file jboss sonatype

First, software preparation
1, apache-maven-3.0-bin.tar.gz:http://www.apache.org/dyn/closer.cgi/maven/binaries/apache-maven-3.0-bin.tar.gz
2, nexus-oss-webapp-1.8.0-bundle.tar.gz:http://nexus.sonatype.org/downloads/

Second, MAVEN installation configuration
1. Create user groups and users who need to operate MAVEN (if not created with root installation)
Java code
    1. #groupadd Configer //create user groups
    2. #useradd-G Configer configer //create user and specify user group
    3. #passwd configer //assigning passwords to users

2. Create an extract directory and extract the apache-maven-3.0-bin.tar.gz file to the specified directory

Java code
    1. #cd/opt
    2. #mkdir maven
    3. #chown-R configer:configer/opt/maven
    4. #chmod 755 /opt/maven
    5. #su-L Configer
    6. #tar-zvxf apache-maven-3.0-bin.tar.gz


2. Configure Environment variables
Java code
    1. #vi/home/configer/.bash_profile

Add the following line to the file:
Java code
    1. m2_home=/opt/maven/apache-maven- 3.0
    2. Export M2_home
    3. path= $PATH: $M 2_home/bin
    4. Export PATH


3. View version
Java code
    1. #cd/opt/maven/apache-maven-3.0/bin
    2. #mvn--version

If version information is displayed, it should be created under the ${user} directory. M2 directory

4. View. M2 Directory
Java code
    1. #cd/home/configer/.m2
    2. If you do not have a. M2 directory, you can manually add a
    3. #mkdir. M2


5. If you need to assign the MAVEN repository directory to a different directory, modify the configuration file Settings.xml file in conf under the MAVEN installation directory
Java code
    1. #vi/opt/maven/apache-maven-3.0/conf/settings.xml
    2. Open the <localRepository>....</localRepository> comment in the file
    3. or add in the file added under this comment
    4. <localrepository>your Repository path</localrepository>



Ii. Building a Nexus
1. Unzip the nexus-oss-webapp-1.8.0-bundle.tar.gz file to the specified directory
Java code
    1. #tar-zvxf nexus-oss-webapp-1.8. 0 -bundle.tar.gz


2. Start Nexus
Java code
    1. #cd/opt/maven/nexus-oss-webapp-1.8. 0 /BIN/JSW
    2.   
    3. Select the version of your machine:
    4.   
    5. #cd linux-x86-/
    6. #./nexus Start
    7.   
    8. Restart :
    9. #./nexus Restart
    10. Stop:
    11. #./nexus Stop


3. Run Nexus
In the browser, type: Http://localhost:8081/nexus
You can see the Nexus's homepage, click on the upper right corner of the log in
The default user name and password are: admin/admin123
After running, a Nexus working directory will be generated automatically sonatype-work,nexus the downloaded jar package will be stored in
In Sonatype-work/nexus/storage

4. Configuration
1) Click on the left menu repositories
In the list on the right, respectively,
Java code
    1. Apache Snapshots
    2. Codehaus Snapshots
    3. Maven Central

The download Remote Index configuration of three repository is changed to true, and the settings are saved.
Then right click on the list of three repository, click Reindex

2) Add new repository, some of the more common jar packages may not be found in the nexus provided by the repository,
Generally more commonly used are
Java code
    1. two of JBoss:
    2. http://repository.jboss.org/maven2/
    3. http://repository.jboss.org/nexus/content/repositories/releases/
    4. Sun's:
    5. http://download.java.net/maven/2/
    6. K-int's:
    7. http://developer.k-int.com/maven2/
    8.   
    9. because looking for Juel:juel-impl:2.2. 1 this jar package, so I also added a look for myself:
    10. http://repository.exoplatform.org/content/groups/public/


To add a step:
Java code
    1. Click Add->proxy repository-> to fill in the Repository ID, Repository Name, and other defaults for remote Storage location.


3) Add the new repository to the public repositories
In the configuration of public repositories, add all the items in the multiple-selection select to the left, and then save.

4) Add your own jar package
Java code
    1. in the repository list there is a 3rd party, that is, a third side jar package, click to see a Artifact Upload tab, click, fill in the appropriate information.
    2. GAV Definition General choice GAV Parameters
    3. then add Group:Artifact:Version:Package
    4. Example Juel:juel-impl:2.2. 1 : Jar


Then select the jar package to upload and save

5) Set up proxy server in Nexus
Select the server option in the left Administrator menu, and in the lower middle of the page that opens on the right, there is a selection: Default HTTP proxy Settings (optional) selects the check box and fills in the appropriate proxy server information.

6) Write your own settings.xml, the file content is as follows:
Java code
  1. <settings>
  2. <proxies>
  3. <proxy>
  4. <id>normal</id>
  5. <active>true</active>
  6. <protocol>http</protocol>
  7. <username>deployment</username>
  8. <password>deploy</password>
  9. 8081/nexus
  10. <port></port>
  11. <nonproxyhosts>localhost:8081/nexus</nonproxyhosts>
  12. </proxy>
  13. </proxies>
  14.   
  15. <mirrors>
  16. <mirror>
  17. <!--This was used to direct the public snapshots Repo in the
  18. Profile Below a different Nexus group --
  19. <id>nexus-public-snapshots</id>
  20. <mirrorOf>public-snapshots</mirrorof>
  21. <url>http://localhost:8081/nexus/content/groups/public-snapshots</url>
  22. </mirror>
  23. <mirror>
  24. <!--This sends everything else
  25. <id>nexus</id>
  26. <mirrorOf>*</mirrorOf>
  27. <url>http://localhost:8081/nexus/content/groups/public</url>
  28. </mirror>
  29. </mirrors>
  30.     
  31. <profiles>
  32. <profile>
  33. <id>development</id>
  34. <repositories>
  35. <repository>
  36. <id>central</id>
  37. <url>http://central</url>
  38. <releases><enabled>true</enabled></releases>
  39. <snapshots><enabled>true</enabled></snapshots>
  40. </repository>
  41. </repositories>
  42. <pluginRepositories>
  43. <pluginRepository>
  44. <id>central</id>
  45. <url>http://central</url>
  46. <releases><enabled>true</enabled></releases>
  47. <snapshots><enabled>true</enabled></snapshots>
  48. </pluginRepository>
  49. </pluginRepositories>
  50. </profile>
  51. <profile>
  52. <!-- This profile would allow snapshots to being searched when activated-->
  53. <id>public-snapshots</id>
  54. <repositories>
  55. <repository>
  56. <id>public-snapshots</id>
  57. <url>http://public-snapshots</url>
  58. <releases><enabled>false</enabled></releases>
  59. <snapshots><enabled>true</enabled></snapshots>
  60. </repository>
  61. </repositories>
  62. <pluginRepositories>
  63. <pluginRepository>
  64. <id>public-snapshots</id>
  65. <url>http://public-snapshots</url>
  66. <releases><enabled>false</enabled></releases>
  67. <snapshots><enabled>true</enabled></snapshots>
  68. </pluginRepository>
  69. </pluginRepositories>
  70. </profile>
  71. </profiles>
  72. <activeProfiles>
  73. <activeProfile>development</activeProfile>
  74. </activeProfiles>
  75. </settings>

Copy the settings.xml file to the ${USER}/.M2 directory

7) Testing
Create a MAVEN project
Java code
    1. #mvn archetype:generate

If you create a Web project, you can choose 83
Fill in the appropriate information, MAVEN will download the corresponding jar package from the IP, and see the address should be localhost
After the project is successfully created, place your own Pom.xml file in the project and execute
Java code
    1. #mvn Install or #mvn Package

MVN will download the jar dependencies defined by the Pom.xml file

After the download is complete, you can see your own jar package in the. M2/repository directory, if not specified, in the repository directory you specified.

So far, our MAVEN installation and the set-up of the business are complete.

Linux installation configuration maven3.0 and setting up a Nexus

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.