环境:linux centos6.5
安装包:nexus-2.12.0-01-bundle.tar.gz
安装
1.将文件上传到目录/usr/local/software
2.我的安装包目录/usr/loca/nexus 在local目录下新建文件夹
[root@izwz96lxm6wxjauv4rfcnqz local]# mkdir nexus
3.进入nexus目录
[root@izwz96lxm6wxjauv4rfcnqz local]# cd nexus/
4.解压
[root@izwz96lxm6wxjauv4rfcnqz nexus]#
tar -zxvf /usr/local/software/nexus-2.12.0-01-bundle.tar.gz
这里解压后,会有两个文件夹,一个是 nexus-2.12.0-01,另外一个是sonatype-work
5.启动
[root@izwz96lxm6wxjauv4rfcnqz tomcats]
/usr/local/nexus/nexus-2.12.0-01/bin/nexus start
这里可以会有警告:
如果需要避免该问题,那么在cd 到bin 目录下找到nexus,然后修改该文件 (添加RUN_AS_USER=root)
[root@izwz96lxm6wxjauv4rfcnqz tomcats]#
vim /usr/local/nexus/nexus-2.12.0-01/bin/nexus
再次启动,过程比较缓慢,需要稍等一段时间:
[root@izwz96lxm6wxjauv4rfcnqz tomcats]
/usr/local/nexus/nexus-2.12.0-01/bin/nexus start
6.开发端口,浏览器访问访问:http://服务器IP:8081/nexus/
手动下载更新索引
- 需要下面3个文件:
链接:https://pan.baidu.com/s/11oQWfhy4tK4S186nUMBM6g
提取码:i35k - 复制这3个文件到index目录下,这个是我创建的一个目录
- 进入index目录,执行解压命令:
[root@linux index]# java -jar indexer-cli-5.1.0.jar -u nexus-maven-repository-index.gz -d indexer
- 解压过程比较久,完成可以在indexer目录看到以下文件
[root@linux indexer]# ls
_4j.fdt _4j.fnm _4j.nrm _4j.tii segments_2 timestamp
_4j.fdx _4j.frq _4j.prx _4j.tis segments.gen
- 然后将该目录下的文件拷贝到central-ctx目录下:
[root@linux indexer]# cp * /usr/local/nexus/sonatype-work/nexus/indexer/central-ctx/
- 重启nexus,开放端口,在浏览器中访问:
使用nexus私服
- 自动发布构建到私服,需要做下面的配置:
pom.xml
<distributionManagement>
<repository>
<id>releases</id>
<url>http://你的ip:端口/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://你的ip:端口/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
settings.xml
<server>
<id>releases</id>
<username>admin</username>
<password>你的密码</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>你的密码</password>
</server>
然后在项目中deploy即可
当然也可以使用命令:
mvn deploy:deploy-file -DgroupId=你的groupId -DartifactId=你的artifactId
-Dversion=版本 -Dpackaging=jar
-Dfile=你的jar文件路径
-Durl=你要发布到的仓库的url
-DrepositoryId=snapshots 或 realease
你可以看到:
发布构建完成.
- 从nexus仓库下载构建:
修改settings.xml文件的镜像,使从私服下载
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<name>local nexus repository</name>
<url>http://192.168.80.134:9090/nexus/content/groups/public/</url>
</mirror>
修改pom.xml (只对当前项目有效)
<repositories>
<repository>
<id>public</id>
<name>maven repository</name>
<url>http://192.168.80.134:9090/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
或者修改settings.xml (对本机的所有项目有效)
<profiles>
<profile>
<id>public</id>
<repositories>
<repository>
<id>public</id>
<name>maven repository</name>
<url>http://192.168.80.134:9090/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
.....
<activeProfiles>
<activeProfile>public</activeProfile>
</activeProfiles>
修改itrip总工程的pom.xml,添加如下依赖:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>4.1</junit.version>
<sources.plugin.verion>2.4</sources.plugin.verion>
<cas.client.core.version>3.4.1</cas.client.core.version>
<version.jackson>2.4.4</version.jackson>
<jackson.verson>2.8.7</jackson.verson>
</properties>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.2.4.Final</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
<version>1.1.6</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.1.7.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>4.1.7.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<!-- modify by hanlu 2017 5-10 -->
<!--<scope>test</scope>-->
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>3.2.5</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.6.12</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>4.1.7.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>4.1.7.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.7.12</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>4.1.7.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
<version>4.1.7.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.12</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.21</version>
<exclusions>
<exclusion>
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>4.1.7.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>4.1.7.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.1.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.1.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.1.7.RELEASE</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.18</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.12</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.1.7.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.1</version>
<exclusions>
<exclusion>
<artifactId>commons-io</artifactId>
<groupId>commons-io</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.2.2</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.1.0</version>
<exclusions>
<exclusion>
<artifactId>commons-pool</artifactId>
<groupId>commons-pool</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.31</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.4.0</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml</groupId>
<artifactId>classmate</artifactId>
</exclusion>
<exclusion>
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
<exclusion>
<artifactId>spring-beans</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>spring-context</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>guava</artifactId>
<groupId>com.google.guava</groupId>
</exclusion>
<exclusion>
<artifactId>jackson-annotations</artifactId>
<groupId>com.fasterxml.jackson.core</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.4.0</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>19.0</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-jdk8</artifactId>
<version>1.1.0.Final</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.verson}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.verson}</version>
<exclusions>
<exclusion>
<artifactId>jackson-annotations</artifactId>
<groupId>com.fasterxml.jackson.core</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.verson}</version>
</dependency>
</dependencies>
修改itrip-biz 工程的pom.xml,添加如下依赖:
暂无
修改itrip-search工程的pom.xml,添加如下依赖:
<dependencies>
......
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-solrj</artifactId>
<version>5.3.1</version>
</dependency>
</dependencies>
修改itrip-auth工程的pom.xml,添加如下依赖:
<dependencies>
........
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.7</version>
</dependency>
<dependency>
<groupId>cn.itrip.ccprestsms</groupId>
<artifactId>itrip-ccprestsms</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
修改itrip-trade工程的pom.xml,添加如下依赖:
<dependencies>
<dependency>
<groupId>cn.itrip.alipay</groupId>
<artifactId>itrip-alipay</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.3</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
修改itrip-util工程的pom.xml,添加如下依赖:
<dependencies>
<dependency>
<groupId>com.belerweb</groupId>
<artifactId>pinyin4j</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>cz.mallat.uasparser</groupId>
<artifactId>uasparser</artifactId>
<version>0.6.0</version>
</dependency>
</dependencies>
修改itrip-dao工程的pom.xml,添加如下依赖:
暂无
修改itrip-beans工程的pom.xml,添加如下依赖:
暂无
然后就可以reimport ,项目会自动从你配置的私服中下载所需要的依赖。