1.maven和eclipse整合 html
参考以前的文章:http://my.oschina.net/OutOfMemory/blog/178512 java
2.nexus的安装与使用 linux
nexus是maven的一个私服,平时咱们本身搞本身项目的话可能并不会考虑这些,所有构件都须要经过maven的中央仓库和第三方的Maven仓库下载到本地,但若是在一个团队中,全部人都重复的从maven仓库下 载构件无疑加大了仓库的负载和浪费了外网带宽,也有不少状况下项目的开发都是在内网进行的,链接不到maven仓库,这时候就须要架设一台maven的私服了。 apache
2.1下载:http://www.sonatype.org/nexus/archived/ 我这边下载的是nexus-2.9.0-bundle.zip windows
2.2启动:解压之后在nexus-2.9.0-bundle\nexus-2.9.0-04\bin\jsw 不一样操做系统有各自的启动方式
windows-x86-64:运行console-nexus.bat进行启动
linux-x86-64:
tomcat
./wrapper ../conf/wrapper.conf
2.3访问地址:http://127.0.0.1:8081/nexus
app
2.4登陆:能够点击界面右上角的Log In进行登陆,用户名密码:admin/admin123 eclipse
点击左侧的Repositories出现如上界面 maven
2.5介绍: svn
Public Repositories: 仓库组
3rd party: 没法从公共仓库得到的第三方发布版本的构件仓库
Apache Snapshots: 用了代理ApacheMaven仓库快照版本的构件仓库
Central: 用来代理maven中央仓库中发布版本构件的仓库
Central M1 shadow: 用于提供中央仓库中M1格式的发布版本的构件镜像仓库
Codehaus Snapshots: 用来代理CodehausMaven 仓库的快照版本构件的仓库
Releases: 用来部署管理内部的发布版本构件的宿主类型仓库
Snapshots: 用来部署管理内部的快照版本构件的宿主类型仓库
咱们平时关注比较多的就是 public Repositories,3rd party, Releases,Snapshots
2.6eclipse中maven的下载与配置
maven下载:http://maven.apache.org/download.cgi 我这边下载的是apache-maven-3.1.1
依次打开window->Preferences-maven以下界面:
默认帮咱们设置的本地仓库是:C:\Users\Administrator\.m2,能够打开settings.xml
<!-- localRepository | The path to the local repository maven will use to store artifacts. | | Default: ${user.home}/.m2/repository <localRepository>/path/to/local/repo</localRepository> -->
默认的下载位置就是:${user.home}/.m2/repository,也就是C:\Users\Administrator\.m2\repository
C盘容易满,全部不建议放在默认路径下
固然这边默认的位置是能够修改的,好比我这边把位置改为了:
相应的settings.xml中作以下设置:
<localRepository>D:\mvn2\myCenterRepository</localRepository>2.7配置从Nexus下载构件
2.7.1在settings.xml中配置Nexus仓库
maven提供了profile来配置仓库信息:
<profiles> <profile> <id>myprofile</id> <repositories> <repository> <id>central</id> <url>http://central</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>central</id> <url>http://central</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </pluginRepository> </pluginRepositories> </profile> </profiles>
激活profiles:
<activeProfiles> <activeProfile>myprofile</activeProfile> </activeProfiles>
配置镜像:
<mirrors> <mirror> <id>nexus</id> <url>http://127.0.0.1:8081/nexus/content/groups/public/</url> <mirrorOf>*</mirrorOf> </mirror> </mirrors>这里配置mirrorOf的值为*,表明maven的全部访问请求都会指向到Nexus仓库组。
2.7.2固然也能够在项目的pom文件中进行配置,这个每一个项目要作相同的配置,不推荐使用。
2.8部署构件到Nexus
2.5中介绍的,3rd party和Releases是咱们常常须要部署的2个地方。
一个是没法从公共仓库得到的第三方发布版本的构件仓库,另外一个是用来部署管理内部的发布版本构件的宿主类型仓库。
From POM:若是要部署的构件自己就是maven项目,须要提供pom.xml文件和jar包
GAV Parameters:不是maven项目的构件,只须要提供jar包
个人理解是,若是构件的项目自己须要依赖其余项目,那么须要使用From POM,若是不依赖其余项目,那么使用From POM和GAV Parameters均可以
3.Hudson的安装和使用
Hudson是Jenkins的前身,是基于Java开发的一种持续集成工具,用于监控程序重复的工做,持续的软件版本发布/测试项目。
1.下载:http://hudson-ci.org/ 我这边下的版本是hudson-3.2.2.war
2.安装,将hudson-3.2.2.war放入tomcat中就能够,启动tomcat就能够了,访问地址:http://localhost:8080/hudson-3.2.2/
刚进主界面须要咱们选择要安装的插件:
Hudson Subversion Plug-in : 整合svn的一款插件
maven和ant的插件都已经默认安装了。
固然也能够进入:系统管理->Manage Plugins using Classic Plugin Manager,从新选择须要安装的插件
3.系统配置
系统管理->系统设置
jdk配置,ant配置,maven配置
固然还能够进行其余配置,好比邮件提醒等。
注:此处若是本地下载的是最新的apache-maven-3.3.3,没法被hudson调用,由于3.3.3之后bin里面的可执行文件变了,应该须要安装Hudson Maven3 Plugin插件可使用(未试)
4.新建任务
新建任务,指定名称(如test),选择“构建一个自由风格的软件项目”。
5.配置svn
注:此处若是须要svn账号,点击enter credential,选择:User name/password authentication
6.build
能够选择多种build方式,咱们选择Invoke Maven2(Legacy)
7.下面就能够点击左上角的“当即构建”了
Hudson将首先从svn下载资源,而后执行maven build项目。
点击右边的小黑框能够查看日志输出
另附:
1.本地的Hudson根目录:C:\Users\Administrator\.hudson\jobs
2.hudson的环境变量 http://blog.sina.com.cn/s/blog_b4b4f2a801018vsq.html