1、环境介绍
jdk:1.7
maven:3.3.3
下载地址:http://pan.baidu.com/s/1c2qeS1M
nexus:2.12.1-01
下载地址:http://pan.baidu.com/s/1geSYkVL
eclipse:4.5.2以及maven插件
2、环境安装
jdk:这个基本的都要有了,java_home,classpath,path都要配好了-环境变量
JAVA_HOME:C:\Program Files\Java\jdk1.7.0_79
CLASSPATH:.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;
PATH:%JAVA_HOME%\bin;
maven:配置一个m2_home环境变量;
M2_HOME:C:\apache-maven-3.3.3
3、程序安装
JDK此处就略过了
maven:只需要解压,配置好环境变量就好了
nexus:只需要解压就可以运行了
4、程序配置
nexus,解压就可以运行了
上图是我解压后转到启动的目录,我只是用过第一个,直接启动的,后面以服务方式的,我没测试,这个目录的上级,有根据不同的系统,选择不同的启动文件夹,可以自己选择
双击以命令窗口方式运行
程序启动完成后,浏览器输入地址:http://localhost:8081/nexus/
便可以访问了
至此,nexus服务器安装完毕
5、maven、nexus配置
maven配置
打开maven的安装目录下的conf文件夹中的setting.xml
1、配置本地maven的maven库,maven下载的jar包,都放到此下面(<localRepository>F:/qsjh_mvn_repo</localRepository>)
2、配置链接nexus的用户名密码信息,在servers标签中间配置
注:此处的用户名,密码,就是你nexus的用户名密码,至关重要,否则maven是下载不了jar包的
<server>
<id>nexus</id>
<username>admin</username>
<password>111111</password>
</server>
<server>
<id>nexus_snapshots</id>
<username>admin</username>
<password>111111</password>
</server>
<server>
<id>nexus_releases</id>
<username>admin</username>
<password>111111</password>
</server>
3、配置maven的镜像地址
注:此处是只用maven时要用到的,我用eclipse,在eclipse的pom文件里面还需要配置的
这里的id,要跟servers里面配置的id一致,否则连不上,这个配置好后,就会从这里下载jar包了
<mirror>
<id>nexus-releases</id>
<mirrorOf>*</mirrorOf>
<url>http://localhost:8081/nexus/content/groups/public</url>
</mirror>
<mirror>
<id>nexus-snapshots</id>
<mirrorOf>*</mirrorOf>
<url>http://localhost:8081/nexus/content/repositories/snapshots</url>
</mirror>
<mirror>
<id>nexus_releases</id>
<mirrorOf>*</mirrorOf>
<url>http://localhost:8081/nexus/content/repositories/releases</url>
</mirror>
6、eclipse配置
eclipse中的maven配置
新建一个maven的web项目,建好后,要把jdk更改为1.7
修改项目的pom.xml文件
1、增加tomcat插件
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<port>9090</port>
<uriEncoding>UTF-8</uriEncoding>
</configuration>
</plugin>
</plugins>
2、增加仓库地址,插件地址,以及打包上传到nexus地址
注:打包地址中的id,必须跟maven的servers中配置的id一致
<repositories>
<repository>
<id>nexus</id>
<name>nexus</name>
<url>http://localhost:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<name>nexus</name>
<url>http://localhost:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<distributionManagement>
<repository>
<id>nexus_releases</id>
<name>core Release Repository</name>
<url>http://localhost:8081/nexus/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>nexus_snapshots</id>
<name>core Snapshots Repository</name>
<url>http://localhost:8081/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
至此,项目已经可以运行了,下面来说明运行的配置,做完下面两步,项目就可以跑起来了。
7、下面说明jar包发布到nexus中去的方法
第一步
新建一个类,发布了,总不能啥都没有把?
第二步还是这样
第三步
第四步:查看发布的结果(可以看到已经发布到sanpshots版本库中了)
第五步想要发布到release中,需要修改pom文件中,修改此处的后缀为release,即可发布到release版本库中。嘎嘎,这个很少有地方提到
鉴于这一篇篇幅太长,时间有点长了,nexus的配置,将于下一篇中介绍吧!干了三四个小时了都!有问题,提出来,大家一起交流