如何安装sonarsnatype nexuss

5778人阅读
Java(11)
CentOS Jenkins + Sonar + Nexus 环境搭建
1.&&Nexus篇
在Centos上安装
如果机器上是JDK1.6的话,nexus-2.5.1是最后一个支持JDK1.6的版本。
下载地址:
我这里使用FTP工具上传到服务器上。执行命令的时候如果遇到没有权限的地方用chmod改变文件权限。
设置为系统自启动服务(使用root用户)
# cd /etc/init.d/
# cp/usr/local/jdk/nexus-2.5.1-01/bin/jsw/linux-x86-64/nexus nexus
编辑/etc/init.d/nexus文件,添加以下变量定义:
NEXUS_HOME=/usr/local/jdk/nexus-2.5.1-01
PLATFORM=linux-x86-64
PLATFORM_DIR=&${NEXUS_HOME}/bin/jsw/${PLATFORM}&
修改以下变量:
WRAPPER_CMD=&${PLATFORM_DIR}/wrapper&
WRAPPER_CONF=&${PLATFORM_DIR}/../conf/wrapper.conf&
PIDDIR=&${NEXUS_HOME}&
修改如下变量,设置启动用户为ycftp(这里用你自己的用户)
RUN_AS_USER=ycftp
执行命令添加nexus自启动服务
&# chkconfig –add nexus
# chkconfig –levels 345 nexus on
执行如下命令启动、停止nexus服务
&# service nexus start
# service nexus stop
启动后可通过访问
用admin/admin123登陆
登陆后点击左侧Repositories,将下图所示设置为true,就可以搜索了
这个时候还搜索不到
需要再右击选项点击 Repair Index如下所示
&修复完成后便可以搜索了。
2.&&Jenkins篇
添加Jenkins的源(repository):
$ sudo wget -O/etc/yum.repos.d/jenkins.repo http://jenkins-ci.org/redhat/jenkins.repo
$ sudo rpm--import
不然你在启动jenkins服务的时候他会说你没有什么key啥的。
安装Jenkins:
$ sudo yum installjenkins
安装完成后,有如下相关目录:
/usr/lib/jenkins/:jenkins安装目录,WAR包会放在这里。
注意修改端口号
/etc/sysconfig/jenkins:jenkins配置文件,“端口”,“JENKINS_HOME”等都可以在这里配置。内容如下:
Development/Jenkins
## Description: Configuration for theJenkins continuous build server
## Default:
&/var/lib/jenkins&
## ServiceRestart: jenkins
# Directory where Jenkins store itsconfiguration and working
# files (checkouts, build reports, artifacts,...).
JENKINS_HOME=&/var/lib/jenkins&
## Default:
## ServiceRestart: jenkins
# Java executable to run Jenkins
# When left empty, we'll try to find thesuitable Java.
JENKINS_JAVA_CMD=&&
## Default:
## ServiceRestart: jenkins
# Unix user account that runs the Jenkinsdaemon
# Be careful when you change this, as youneed to update
# permissions of $JENKINS_HOME and/var/log/jenkins.
JENKINS_USER=&jenkins&
## Default:
&-Djava.awt.headless=true&
## ServiceRestart: jenkins
# Options to pass to java when runningJenkins.
JENKINS_JAVA_OPTIONS=&-Djava.awt.headless=true&
integer(0:65535)
## Default:
## ServiceRestart: jenkins
# Port Jenkins is listening on.
# Set to -1 to disable
JENKINS_PORT=&8085&
integer(0:65535)
## Default:
## ServiceRestart: jenkins
# Ajp13 Port Jenkins is listening on.
# Set to -1 to disable
JENKINS_AJP_PORT=&8019&
integer(1:9)
## Default:
## ServiceRestart: jenkins
# Debug level for logs -- the higher thevalue, the more verbose.
# 5 is INFO.
JENKINS_DEBUG_LEVEL=&5&
## Default:
## ServiceRestart: jenkins
# Whether to enable access logging or not.
JENKINS_ENABLE_ACCESS_LOG=&no&
## Default:
## ServiceRestart: jenkins
# Maximum number of HTTP worker threads.
JENKINS_HANDLER_MAX=&100&
## Default:
## ServiceRestart: jenkins
# Maximum number of idle HTTP workerthreads.
JENKINS_HANDLER_IDLE=&20&
## Default:
## ServiceRestart: jenkins
# Pass arbitrary arguments to Jenkins.
# Full option list: java -jar jenkins.war--help
JENKINS_ARGS=&&
我这里修改端口号为8085,避免和本机tomcat冲突
启动Jenkins
sudo servicejenkins start
启动后用 访问
3.&&Sonar篇
我用的ftp工具上传到服务器。
编辑~/.bash_profile,添加环境变量
添加SONAR_RUNNER_HOME(就是sonar-runner-2.4的全路径名,比如/usr/local/sonar-runner-2.4)环境变量,并将SONAR_RUNNER_HOME/bin加入PATH变量中
记得使环境变量生效
source ~/.bash_profile
我这里使用mysql数据库,但不说mysql怎么安装了。
先配置Sonar要用的数据库环境:
创建数据库
1)& 在mysql中执行如下脚本创建数据库及mysql用户
CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_
CREATE USER 'sonar' IDENTIFIED BY 'sonar';
GRANT ALL ON sonar.* TO 'sonar'@'%' IDENTIFIED BY 'sonar';
GRANT ALL ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY 'sonar';
2)编辑${SONAR_HOME}/conf/sonar.properties配置数据库:
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true
# Optionalproperties
sonar.jdbc.driverClassName:com.mysql.jdbc.Driver
3)配置DB驱动包
如果使用Oracle数据库,必须手动复制驱动类到${SONAR_HOME}/extensions/jdbc-driver/oracle/目录下。其它支持的数据库默认提供了驱动,http://docs.codehaus.org/display/SONAR/Analysis+Parameters 列举了一些常用的配置及默认值.
修改sonar配置文件
编辑sonar所在的目录(比如/usr/local/sonar-4.4)中conf/sonar.properties文件,配置数据库设置,默认已经提供了各类数据库的支持,只要将注释去掉就可以。这里使用mysql,因此取消mysql模块的注释,并将sonar中原有的嵌入式的数据库的jdbc.url注释掉。
#vi&sonar.properties
#需要注释下面这条语句
#sonar.jdbc.url=jdbc:h2:tcp://localhost:9092/sonar
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=
utf8&rewriteBatchedStatements=true
#&Optional&properties
sonar.jdbc.driverClassName=com.mysql.jdbc.Driver
修改sonar-runner的配置文件
切换至sonar-runner的安装目录下,修改sonar-runner.properties根据实际使用数据库情况取消相应注释,这里需要和sonar.properties中保持一致。
#Configure here general information about the environment, such as SonarQube DB details for example
#No information about specific project should appear here
#----- Default SonarQube server
sonar.host.url=http://localhost:9000
#----- PostgreSQL
#sonar.jdbc.url=jdbc:postgresql://localhost/sonar
#----- MySQL
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8
sonar.jdbc.driverClassName=com.mysql.jdbc.Driver
#----- Oracle
#sonar.jdbc.url=jdbc:oracle:thin:@localhost/XE
#----- Microsoft SQLServer
#sonar.jdbc.url=jdbc:jtds:sqlserver://localhost/SelectMethod=Cursor
#----- Global database settings
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
#----- Default source code encoding
sonar.sourceEncoding=UTF-8
#----- Security (when 'sonar.forceAuthentication' is set to 'true')
sonar.login=admin
sonar.password=admin
运行如下命令启动sonar,其它操作系统sonar均提供了启动脚本
$ ${SONAR_HOME}/bin/linux-x86-64/sonar.sh start
如果遇到wrapper没有执行权限,用chmod命令赋予权限
chmod 777 wrapper
在浏览器中访问: http://yourip:9000/ ,运行界面如下:
配置为自启动服务
使用root账户或者开启sudo权限操作。
创建自启动脚本文件/etc/init.d/sonar
# vi/etc/init.d/sonar
添加如下内容
# rc file for SonarQube
# chkconfig: 345 96 10
# description: SonarQube system (www.sonarsource.org)
### BEGIN INIT INFO
# Provides: sonar
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: SonarQube system (www.sonarsource.org)
# Description: SonarQube system (www.sonarsource.org)
### END INIT INFO
/usr/bin/sonar $*
添加启动服务
# ln -s $SONAR_HOME/bin/linux-x86-64/sonar.sh /usr/bin/sonar
# chmod 755 /etc/init.d/sonar
# chkconfig --add sonar
与Jenkins集成
在jenkins的插件管理中选择安装sonar jenkins plugin,该插件可以使项目每次构建都调用sonar进行代码度量。具体配置方式不再叙述。
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:160386次
积分:1726
积分:1726
排名:千里之外
原创:29篇
译文:15篇
评论:34条
(2)(3)(1)(2)(1)(2)(1)(2)(2)(1)(1)(1)(17)(1)(2)(4)(1)(2)(1)(1)(1)Posts - 30,
Articles - 0,
Comments - 344
20:28 by 飘扬的红领巾, ... 阅读,
    但凡一个略有规模的项目都需要一个持续集成环境的支撑,为什么需要持续集成环境,我们来看一个例子。假如一个项目,由A、B两位程序员来协作开发,A负责前端模块,B负责后端模块,前端依赖后端。A和B都习惯使用SVN作为代码管理工具,他们分别开始工作,一个功能完成后会提交到SVN,以便对方能够使用。一天B告诉A,我的某个功能完成了,提交到SVN,你更新下来试一下。A便从SVN更新下来代码,结果一试,我檫报错,于是告诉B你的代码有问题,B检查了一下确实有问题,然后B经过1个小时修改后,重新上传到SVN,A更新下来可以使用了。又过了几个小时,A发现B的代码仍然有问题,B检查了半天,没找到问题所在,后来开发组长检查他们的代码发现是两个人使用不同版本的jar包导致的,这个问题确认难以发现,A把jar包的版本弄得和B一样,A和B又开始继续工作。终于有一天项目完成了,需要发布程序,这时A从自己的开发环境上编译一个版本,把他上传到服务器上,程序运行的前几天比较稳定,后来A有点急事请假了,但服务器上的程序这时好像出现了问题,这时B只能使用自己的电脑调试、解决问题并试着发一个版本,但因为他平时做后端,对版本发布不是很熟悉,又搞了半天终于弄好了。项目上线了,稳定运行了半年,后来A、B先后离职了,新来的C负责维护这个项目,尽管A、B在离职前做了一些工作交接,但当C真正接手的时候才发现头大,我檫居然注释都没写,有没有这么坑的,由于C开始硬着头皮看代码,发现代码中各种飘逸写法,各种为了临时需求而打的补丁,C几乎抓狂。
    以上的例子有点夸大,但或多或少都可能遇到过,我们需要一种规范来约束这个开发过程,使开发过程严格有序的进行。
从问题出发
就以上面这个例子,我们看其中暴露出了哪些问题:
1、团队彼此协作不流畅,出现彼此阻塞的情况;
2、使用的类库版本不统一,造成难以估计的风险;
3、代码未经严格测试就上传,造成不断的返工;
4、版本发布规范欠缺,版本质量不能保证;
5、代码质量低,其他人难以接手。
    团队开发时,我们常常约定好彼此之间的接口规范,然后开始各自开发,开发完成后,按照接口规范对接起来,这是一个理想的流程,但现实往往不那么顺利,问题常常在于,接口规范可能根据需求变化而经常变更,而且在实际对接时经常发现诸多问题。我们无法通过工具来解决这些问题,只能要求开发人员在制定接口规范时,为可能变更的需求多一些扩展,在开发时多考虑诸多素质,尽量将减少对接过程中的问题。下面将讲述如何使用Maven和Nexus保证开发人员引用统一的类库版本,以及如何将自己开发的模块上传至Nexus服务器,以提供给其他模块引用。
关于Maven和Nexus的搭建在中已经介绍过,在此介绍下主要步骤:
1、下载maven(读:妹吻)和nexus(读:耐克色儿丝):
2、将下载的nexus放置到linux服务器解压并启动:
cd /data/program/nexus-2.3.1-01/bin/jswll
选择自己的系统并进入:
./nexus start
nexus启动成功,访问:
3、将下载的maven解压放置在开发机上(windows),并配置conf目录下的setting.xml文件:
(1)在&settings&&profiles&&/profiles&&/settings&节点之间添加配置:
&profile& &id&dev&/id& &repositories& &repository& &id&local-nexus&/id& &url&http://192.168.6.204:8081/nexus/content/groups/public/&/url& &releases& &enabled&true&/enabled& &/releases& &snapshots& &enabled&true&/enabled& &/snapshots& &/repository& &/repositories& &/profile&
接着在&settings&&/settings&节点之间添加配置:
&activeProfiles& &activeProfile&dev&/activeProfile& &/activeProfiles&
以上配置好了连接Nexus私服。
(2)安装eclipse的m2eclipse插件,并配置maven。
m2eclipse的安装地址:(安装过程略)
安装完成后配置maven:
配置eclipse的maven为本地下载的maven地址。主要为了方便配置和版本管理。
至此,nexus和maven就搭建配置完成了,下面我们要利用这个环境解决两个问题:
1、不同的模块项目都使用统一的类库版本;如spring都使用3.1.2.RELEASE,log4j都使用1.2.17。这样避免因为jar包版本的不同,引发的诸多问题。
2、模块开发完毕后,将编译的库文件发布到nexus私服上,以便其他模块引用。
这里说一下maven的一个特性,继承。简单来说继承就是先建立一个父项目,其他项目如果继承这个父项目,就可以继承这个项目定义的库文件及版本。利用这个特性,我们可以让多个模块都继承一个父项目,而在父项目中定义好类库的版本,这样所有模块都使用统一的类库文件。例如:
建立名为maven-parent的父项目,pom配置为:
&project xmlns=&http://maven.apache.org/POM/4.0.0& xmlns:xsi=&http://www.w3.org/2001/XMLSchema-instance&
xsi:schemaLocation=&http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&&
&modelVersion&4.0.0&/modelVersion&
&groupId&</blogs.leefreeman&/groupId&
&artifactId&maven-parent&/artifactId&
&version&0.0.1-SNAPSHOT&/version&
&packaging&pom&/packaging&
&properties&
&!-- junit --&
&junit.version&4.10&/junit.version&
&!-- servlet --&
&servlet-api.version&2.5 &/servlet-api.version&
&!-- log4j --&
&log4j.version&1.2.17 &/log4j.version&
&!-- commons.codec --&
&commons.codec.version&1.7&/commons.codec.version&
&!-- maven-support --&
&maven-support.version&0.0.1-SNAPSHOT&/maven-support.version&
&project.build.sourceEncoding&UTF-8&/project.build.sourceEncoding&
&/properties&
&dependencyManagement&
&dependencies&
&!-- junit --&
&dependency&
&groupId&junit&/groupId&
&artifactId&junit&/artifactId&
&version&${junit.version}&/version&
&scope&test&/scope&
&/dependency&
&!-- log4j --&
&dependency&
&groupId&log4j&/groupId&
&artifactId&log4j&/artifactId&
&version&${log4j.version}&/version&
&/dependency&
&!-- commons包 --&
&dependency&
&groupId&commons-codec&/groupId&
&artifactId&commons-codec&/artifactId&
&version&${commons.codec.version}&/version&
&/dependency&
&!-- servlet --&
&dependency&
&groupId&javax.servlet&/groupId&
&artifactId&servlet-api&/artifactId&
&version&${servlet-api.version}&/version&
&scope&provided&/scope&
&/dependency&
&/dependencies&
&/dependencyManagement&
&/project&
这个pom定义了一些类库以及它的版本。
然后再建立模块项目:maven-sample(web项目)、maven-support(支撑模块,包括一些工具类以及业务封装,提供给maven-sample引用)。
maven-sample的pom.xml:
&project xmlns=&http://maven.apache.org/POM/4.0.0& xmlns:xsi=&http://www.w3.org/2001/XMLSchema-instance&
xsi:schemaLocation=&http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&&
&modelVersion&4.0.0&/modelVersion&
&groupId&</blogs.leefreeman&/groupId&
&artifactId&maven-parent&/artifactId&
&version&0.0.1-SNAPSHOT&/version&
&artifactId&maven-sample&/artifactId&
&packaging&war&/packaging&
&dependencies&
&dependency&
&groupId&junit&/groupId&
&artifactId&junit&/artifactId&
&/dependency&
&dependency&
&groupId&log4j&/groupId&
&artifactId&log4j&/artifactId&
&/dependency&
&dependency&
&groupId&commons-codec&/groupId&
&artifactId&commons-codec&/artifactId&
&/dependency&
&dependency&
&groupId&javax.servlet&/groupId&
&artifactId&servlet-api&/artifactId&
&/dependency&
&/dependencies&
&finalName&maven-sample&/finalName&
&/project&
maven-support的pom.xml:
&project xmlns=&http://maven.apache.org/POM/4.0.0& xmlns:xsi=&http://www.w3.org/2001/XMLSchema-instance&
xsi:schemaLocation=&http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&&
&modelVersion&4.0.0&/modelVersion&
&groupId&</blogs.leefreeman&/groupId&
&artifactId&maven-parent&/artifactId&
&version&0.0.1-SNAPSHOT&/version&
&artifactId&maven-support&/artifactId&
&packaging&jar&/packaging&
&dependencies&
&dependency&
&groupId&junit&/groupId&
&artifactId&junit&/artifactId&
&/dependency&
&dependency&
&groupId&log4j&/groupId&
&artifactId&log4j&/artifactId&
&/dependency&
&dependency&
&groupId&commons-codec&/groupId&
&artifactId&commons-codec&/artifactId&
&/dependency&
&/dependencies&
&/project&
通过以上配置,maven-sample和maven-support引用的jar包,都会使用相同的版本:
接下来我们解决协作开发的问题,maven-support开发完毕之后,将之发布到nexus服务器,以便maven-sample可以引用。我们需要3步:
1、本地maven的conf目录下的setting.xml,在&servers&&/servers&节点之间添加:
&id&releases&/id&
&username&admin&/username&
&password&admin123&/password&
&id&snapshots&/id&
&username&admin&/username&
&password&admin123&/password&
2、在maven-support项目的pom.xml中,&project&&/project&节点之间添加:
&!-- 构件部署仓库 --&
&distributionManagement&
&repository&
&id&releases&/id&
&name&发布版本仓库&/name&
&url&http://192.168.0.109:8081/nexus/content/repositories/releases/&/url&
&/repository&
&snapshotRepository&
&id&snapshots&/id&
&name&快照版本仓库&/name&
&url&http://192.168.0.109:8081/nexus/content/repositories/snapshots/&/url&
&/snapshotRepository&
&/distributionManagement&
3、对maven-support项目进行编译,并执行发布命令:
可以看到maven-support已经成功发布到nexus私服中:
这样maven-sample就可以引用maven-support模块,而开发maven-support的人则可以继续开发,持续发布新版本。
&#160;&#160;&#160; 本文主要介绍maven和nexus的环境搭建,以及怎么使用maven和nexus统一管理库文件和版本,怎么讲自己的模块上传至nexus私服,供其他模块引用。这样我们基本解决了两个问题:
1、团队彼此协作不流畅,出现彼此阻塞的情况;
2、使用的类库版本不统一,造成难以估计的风险;
下一篇将使用jenkins、svn、tomcat以及sonar解决自动化测试、自动化版本发布、代码质量检查等问题。> 博客详情
& & 因为看到网上诸多的公共Maven仓库,以及自己管理Jar包的不方便,趁这次搭建毕设项目环境,把创建Maven项目涉及到的步骤理一遍。
安装Nexus(以Windows32平台举例):
下载Nexus:;
解压nexus-2.6.4-02-bundle.zip至任意目录;
NOTE:Nexus在一个名为Jetty的servlet容器中运行,它使用一个名为Tanuki Java Service Wrapper的本地服务包裹器启动。这个服务包裹器可以被配置成以Windows服务或Unix守护线程的形式运行Nexus。要启动Nexus,你需要为你的平台找到合适的启动脚本。要查看可用平台的列表,查看${NEXUS_HOME}/bin/jsw目录的内容。【】
因此,首先需要安装Wrapper:${NEXUS_HOME}/bin/jsw下找到相应平台,以管理员身份启动install-nexus.bat。
管理员身份(不然会有wrapper &| OpenSCManager failed - Access is denied. (0x5)之类错误)运行CMD,cd进入${NEXUS_HOME}/bin/目录,nexus start启动nexus。
控制台提示wrapper &| nexus started.后,即可进入http://localhost:8081/nexus/进入nexus平台,默认用户名:admin,密码:admin123。
看图快速了解Nexus:
具体的可以参考网上资料,比如。
安装Maven: &
Nexus是用来管理构建(Artifacts)的,Maven是使用这些构建并搭建项目的;
下载Maven:;
解压安装包至任意目录,在环境变量中加入M2_HOME=D:/apache-maven-3.0.4(解压目录),PATH中加入bin路径:%M2_HOME%\bin;
CMD输入命令:mvn -version检查是否正确安装;
接下来就是配置Maven了,这些操作都没有使用命令行,打开位于%M2_HOME%/conf/目录下的setting.xml文件;
主要更改以下几项,【】符号标注,注意看注释: &!--&【localRepository】
&&&|&The&path&to&the&local&repository&maven&will&use&to&store&artifacts.
&&&|&Default:&~/.m2/repository&--&
&&&localRepository&D:\Maven3.0.4\repository&/localRepository&&!--&【servers】
&&&|&This&is&a&list&of&authentication&profiles,&keyed&by&the&server-id&used&within&the&system.
&&&|&Authentication&profiles&can&be&used&whenever&maven&must&make&a&connection&to&a&remote&server.
&&&servers&
&&&&&!--&server
&&&&&|&Specifies&the&authentication&information&to&use&when&connecting&to&a&particular&server,&identified&by
&&&&&|&a&unique&name&within&the&system&(referred&to&by&the&'id'&attribute&below).
&&&&&|&NOTE:&You&should&either&specify&username/password&OR&privateKey/passphrase,&since&these&pairings&are&
&&&&&|&&&&&&&used&together.
&&&&&server&&&
&&&&&&&id&nexus-releases&/id&&&
&&&&&&&username&admin&/username&&&
&&&&&&&password&admin123&/password&&&
&&&&&/server&&!--&【mirrors】
&&&|&This&is&a&list&of&mirrors&to&be&used&in&downloading&artifacts&from&remote&repositories.
&&&|&It&works&like&this:&a&POM&may&declare&a&repository&to&use&in&resolving&certain&artifacts.
&&&|&However,&this&repository&may&have&problems&with&heavy&traffic&at&times,&so&people&have&mirrored
&&&|&it&to&several&places.
&&&|&That&repository&definition&will&have&a&unique&id,&so&we&can&create&a&mirror&reference&for&that
&&&|&repository,&to&be&used&as&an&alternate&download&site.&The&mirror&site&will&be&the&preferred&
&&&|&server&for&that&repository.
&&&mirrors&
&&&&&!--&mirror
&&&&&|&Specifies&a&repository&mirror&site&to&use&instead&of&a&given&repository.&The&repository&that
&&&&&|&this&mirror&serves&has&an&ID&that&matches&the&mirrorOf&element&of&this&mirror.&IDs&are&used
&&&&&|&for&inheritance&and&direct&lookup&purposes,&and&must&be&unique&across&the&set&of&mirrors.
&&&&&|【注意:下面的url换成了xx;其实上面我们安装nexus的时候是在本机,但是实际应用时会放在服务器,所以这里用x提醒下。】
&&&&&mirror&&&&
&&&&&&&id&nexus-releases&/id&&&&
&&&&&&&mirrorOf&*&/mirrorOf&&&&
&&&&&&&url&http://xx.xx.xx.xx:8080/nexus/content/groups/public&/url&&&&
&&&&&/mirror&&&
&&&/mirrors&&&!--&还有各种profiles、activeProfiles&--&
到这里,Maven基本上是就绪状态了,接下来我们为MyEclipse安装Maven插件,然后在MyEclipse支持下,建立Maven项目。
安装MyEclipse的Maven插件(MyEclipse版本为10,不同版本可能会有小差异):
我们采用MyEclipse的在线安装功能安装Maven插件;
打开MyEclipse10,MyEclipse -&&MyEclipse Configuration Center -& Software,点击add site,Name:Maven,URL:;
安装完成之后,可以在MyEclipse的Preferences中看到如下选项:
如图进行相关设置之后,MyEclipse中的Maven插件就生效了,接下来我们就来建一个Maven项目。
MyEclipse中建立Maven项目:
还是看图吧:
接下来,就是利用pom.xml构建你的项目,项目建立会有一个默认的pom.xml,可以先学习下这个文件。pom.xml中的repositories指向刚才搭建的nexus仓库,dependencies则制定需要的具体jar包。初步可以认为pom.xml就是用来管理你需要的jar包,而不用一个个去网上搜,或者在本地自己手动维护一堆jar包;当然这只是初步,Maven还有其他方面的强大功能,不明觉厉。
&&&&从搭建Nexus开始,到安装Maven及MyEclipse插件,然后创建Maven项目,本文基本把这些步骤理了一遍。接下来在具体使用Maven的过程中肯定会有很多问题,包括使用Maven高效搭建管理项目,或者在MyEclipse环境下使用Maven会遇到一些莫名其妙的问题,这些问题希望能够和各位交流,我也会在后续的文章中补充。
如果文章对你有用,请在收藏之余“顶/赞”一下以示鼓励吧&(/ω\)
人打赏支持
码字总数 22439
支付宝支付
微信扫码支付
打赏金额: ¥
已支付成功
打赏金额: ¥}

我要回帖

更多关于 eclipse安装sonar插件 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信