linux安装nexus
wget http://www.sonatype.org/downloads/nexus-2.2-01-bundle.zip
unzip nexus-2.2-01-bundle.zip
sudo vim /etc/profile/
export NEXUS_HOME=/usr/local/nexus/nexus-2.2-01
export PATH=$NEXUS_HOME/bin:$PATH
chown zhoufeng:zhoufeng $NEXUS_HOME –R
nexus start
访问: http://hostname:8081/nexus
nexus 默认用户
用户名 | 密码 |
admin | amin123 |
将nexus添加到系统服务,并开机启动
chmod 755 $NEXUS_HOME/bin/nexus
cp $NEXUS_HOME/bin/nexus /etc/init.d/
sudo vim etc/init.d/ nexus
修改内容如下:
JAVA_HOME=/data/java/jre1.6.0_37
NEXUS_HOME="/usr/local/nexus/nexus-2.2-01"
APP_NAME="nexus"
APP_LONG_NAME="Sonatype Nexus"
PLATFORM=linux-x86-64
WRAPPER_CMD="${NEXUS_HOME}/bin/jsw/${PLATFORM}/wrapper"
WRAPPER_CONF="${NEXUS_HOME}/conf/wrapper.conf"
sudo chkconfig –add nexus
eclipse配置maven
1、 解压maven
2、 将$MAVEN_HOME 加入环境变量
3、 新建一个仓库文件夹,用作本地仓库
4、 eclipse安装maven插件
5、 eclipse配置maven
发布项目到nexus
1、 新建一个测试项目 GAV为:
<groupId>maven</groupId>
<artifactId>maven-maven1</artifactId>
<version>0.0.1-SNAPSHOT</version>
2、 在pom.xml中配置distributionManagement节点
<distributionManagement>
<repository>
<id>maven-maven1-releases</id>
<name>maven-maven1-releases</name>
<url>http://192.168.1.168:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>maven-maven1-snapshots</id>
<name>maven-maven1-snapshots</name>
<url>http://192.168.1.168:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
3、在settings.xml中配置用来发布该项目的用户
<server>
<id>maven-maven1-releases</id> <!- 这里的id对应上面的id -
<username>deployment</username>
<password>deployment123</password>
</server>
<server>
<id>maven-maven1-snapshots</id>
<username>deployment</username>
<password>deployment123</password>
</server>
4、运行pom.xml clean deploy
配置项目的仓库,指向私服上面的nexus
<repositories>
<repository>
<id>nexus</id> <!- 该地方最好不要改 -
<url>http://192.168.1.168:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
修改settings.xml 配置全局的镜像,让所有的项目都从私服上面下载依赖(如果用这种方式,上面的配置就可以去掉了)
<mirrors>
<mirror>
<id>nexus</id>
<name>internal nexus repository</name>
<url>http://192.168.1.168:8081/nexus/content/groups/public/</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
使用jetty调试web程序。
eclipse 安装 jetty
使用ecliipse在线安装的方式。地址为:http://run-jetty-run.googlecode.com/svn/trunk/updatesite
安装完成后重启eclipse ,然后选中要调试的项目,点击上面的run按钮。
选择run Configurations 进入配置界面,进行如下配置:
在Jetty Webapp 上面右键,新建一个
然后就可以在项目上面右键 - > run - > run jetty
可以以选择 pom.xml -> 右键 -> run as - > run jetty
编译打包项目
依赖的plugin
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>auto-clean</id>
<phase>initialize</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
当打包时向取消项目的自动测试时,可以用maven-surefire-plugin的配置项中的<skipTests>true</skipTests> 跳过测试。
发布项目到私服
1、 登录私服
2、 Repositories–> Add -> 创建一个新的仓库
3、 创建权限Privileges –> Add-> Pepository Target Privilege -> Meven2(All)
4、 添加角色Roles -> Add ->Nexus Role ,然后给Role添加权限
5、 创建用户Users-> Add -> Nexus User ,然后给他权限
6、 在项目中定义发布仓库
<distributionManagement>
<snapshotRepository>
<id>ssh-snapshots</id>
<name>ssh-snapshots-snapshots</name>
<url>http://192.168.1.168:8081/nexus/content/repositories/ssh/</url>
</snapshotRepository>
</distributionManagement>
7、 为该项目配置发布用户,修改settings.xml
<server>
<id>ssh-snapshots</id>
<username>ssh-user</username>
<password>ssh-user</password>
</server>
8、 添加install插件
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.4</version>
<type>pom</type>
</dependency>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.4</version>
</plugin>
9、执行发布 clean deploy
手动添加依赖的jar文件到maven仓库
http://blog.csdn.net/luckarecs/article/details/7091555
MVN 常见问题
http://www.cnblogs.com/BigTall/archive/2011/03/23/1993253.html