`

ubuntu10.04下nexus和maven的安装及配置

 
阅读更多

前提要有jdk环境,官方下载nexus和maven,解压后创建两个文件方便启动和停止nexus

startNexus.sh

#!/bin/bash
echo start nexus
echo nexus url is : http://localhost:8081/nexus
cd ~
cd /media/software/nexus/nexus1.9/nexus-oss-webapp-1.9.1.1/bin/jsw/linux-x86-32
./nexus start
echo start success!

 

stopNexus.sh

#!/bin/bash
echo stop nexus
cd ~
cd /media/software/nexus/nexus1.9/nexus-oss-webapp-1.9.1.1/bin/jsw/linux-x86-32
./nexus stop
echo over!

 

配置maven环境变量:

sudo gedit /etc/profile

 

最后添加如下代码:

#java
export JAVA_HOME=/home/chenjun/java/jdk1.6.0_31
#maven
export M3_HOME=/media/software/maven/apache-maven-3.0.3
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$M3_HOME/bin:$PATH
export CLASSPATH=$CLASSPATH:.:$JAVA_HOME/lib:$JAVA_HOME/jre/

 

执行source /etc/profile 更新配置文件信息,重启电脑

mvn -version 测试是否成功

复制$M3_HOME/conf/settings.xml到~/.m2/目录下面:

可以修改仓库的默认位置:

<localRepository>/media/software/repository</localRepository>

添加代码:

<profile>
      <id>nexus</id>
      <repositories>
        <repository>
          <id>nexus</id>
          <name>nexus</name>
          <url>http://localhost:8081/nexus/content/groups/public</url>
        </repository>
      </repositories>
      <pluginRepositories>
          <pluginRepository>
              <id>nexus</id>
              <name>nexus</name>
              <url>http://localhost:8081/nexus/content/groups/public</url>
          </pluginRepository>
      </pluginRepositories>
    </profile>

<activeProfiles>
    <activeProfile>nexus</activeProfile>
  </activeProfiles>

 

在server标签中添加用户和密码。

启动nexus脚本文件。

启动eclipse添加m2e插件,http://download.eclipse.org/technology/m2e/releases,然后添加自己的maven。

 添加下面配置可以修改项目的jdk版本

<profile>
   <id>jdk-1.6</id>
   <activation>
    <activeByDefault>true</activeByDefault>
    <jdk>1.6</jdk>
   </activation>
   <properties>
    <maven.compiler.source>1.6</maven.compiler.source>
    <maven.compiler.target>1.6</maven.compiler.target>
    <maven.compiler.compilerVersion>1.6</maven.compiler.compilerVersion>
   </properties>
  </profile>

 添加下面配置使得所有的下载都通过nexus:

<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<name>nexus</name>
<url>http://localhost:8081/nexus/content/groups/public</url>
</mirror>

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics