Linux环境下Maven仓库的搭建(nexus)及Mavan的简单使用

对Linux及Maven都不熟悉,在网上折腾,然后总结如下:
一.搭建仓库(JDK required):
linux platform, IP:192.168.2.99
1.download apache-maven-x.x.x-bin.tar.gz
2.download nexus-oss-webapp-x.x.x.x-bundle.tar.gz
3. tar -zxvf apache-maven-x.x.x-bin.tar.gz -C /usr/java/
4.add enviroment variable:
     a. vi /etc/profile;
b. append 'MAVEN_HOME=/usr/java/***'
c. append 'PATH=${PATH}:${MAVEN_HOME}/bin'
d. append 'export MAVEN_HOME PATH'
e. source /etc/profile
5.tar -zxvf nexus-oss-webapp-x.x.x.x-bundle.tar.gz -C /usr/java/
6.startup(shutdown) nexus:
a. cd nexus/nexus-oss-webapp-1.9.0.2/bin/jsw/linux-x86-32/
b. ./nexus start(stop)
7.test:
ok, login as admin/admin123 (default)
 
二、使用Mavan仓库:
windows platform, IP:192.168.2.3
1.download and setup apache-maven-x.x.x-bin.zip (D:/maven)
2.add enviroment variable:
new MAVEN_HOME:D:/maven
add to path:%MAVEN_HOME%/bin
test:mvn -version, ok
3.open the file " settings.xml " under the folder "d:/maven/conf"
add the next chars into the file:
       <localRepository>C:/.m2/repository</localRepository>
      <servers>
        <server>   
            <id>nexus-releases</id>   
            <username>admin</username>   
            <password>admin</password>   
        </server>   
        <server>   
            <id>nexus-snapshots</id>   
            <username>admin</username>   
            <password>admin</password>   
        </server>
    </servers>

    <mirrors>
        <mirror>
            <mirrorOf>*</mirrorOf>
            <name>linux-nexus</name>
            <url>http://192.168.2.99:8081/nexus/content/groups/public</url>
            <id>nexus</id>
        </mirror>
    </mirrors>

<profiles>
<profile>
       <id>dev</id>
          <repositories>
             <repository>
                 <id>nexus</id>
                 <url>http://192.168.2.99:8081/nexus/content/groups/public/</url>
                 <releases>
                    <enabled>true</enabled>
                 </releases>
                 <snapshots>
                    <enabled>true</enabled>
                 </snapshots>
              </repository>
            </repositories>            
            <pluginRepositories>
                <pluginRepository>
                    <id>nexus</id>
                    <url>http://192.168.2.99:8081/nexus/content/groups/public</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>
    <activeProfiles>
        <activeProfile>dev</activeProfile>
    </activeProfiles>
save, ok.
4.mkdir "d:/workspace"
5. mvn archetype:generate
6.choose the default selection(16)
7.input some informations(the project name:helloworld)
8.ok, look the dir "D:/workspace", there is a folder "helloworld"
9.open the file " pom.xml " under "helloworld", add some dependencies, example:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5.6.SEC02</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.2.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
10.run the command " mvn install " under "helloword", then, it will download some jars and poms
into "C:/.m2/repository"(default) from 192.168.2.99.
11.convert this maven project to eclipse project:
under the folder "helloworld", run " mvn eclipse:eclipse ".
说明:192.168.2.99是虚拟机中Linux的IP,192.168.2.3是虚拟机中Win7的IP。
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值