1:搭建环境安装
1:Linux环境(centos7)
Linux VM_0_10_centos 3.10.0-514.26.2.el7.x86_64 #1 SMP Tue Jul 4 15:04:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
环境—>腾讯云
2:Java环境安装
1:下载jdk1.8:http://www.oracle.com/technetwork/java/javase/downloads/index.html
2:在/opt目录下建立java目录:mkdir /opt/java
3:解压:tar -zxvf jdk-8u144-linux-x64.tar.gz
4:配置jdk环境
3:maven环境搭建
1:到http://mirror.bit.edu.cn/apache/maven/maven-3/下载maven3的tar包
2:上传到linux上,例如在/opt/maven
3:解压:tar -zxvf 解压文件
4:在/etc/profile配置maven环境
4:nexus环境安装
1:nexus安装包:wget https://sonatype-download.global.ssl.fastly.net/nexus/oss/nexus-2.11.2-03-bundle.tar.gz
2:在/opt/nexus目录下进行解压
3:配置nexus的访问端口:vim /opt/nexus/nexus-2.11.2-03/conf/nexus.properties,该文件有application-port属性,配置端口
4:配置nexus的root用户访问:vim /opt/nexus/nexus-2.11.2-03/bin/nexus,将配置文件里面的属性RUN_AS_USER=ROOT注释消掉
5:开放nexus的web访问端口:
->firewall-cmd –zone=public –add-port=80/tcp –permanent
->firewall-cmd –reload(重新加载防火墙)
->firewall-cmd –list-all(查看开放的端口)
->特别注意:如果是腾讯云,你只需要在xshell控制台进行开放端口就行;如果是阿里云,建议在xshell和阿里云开放端口的页面都开启相关端口
6:nexus的启动与停止:
->到/opt/nexus/nexus-2.11.2-03/bin
->./nexus start–>开启
->./nexus stop–>停止
2:nexus仓库设置
1:登录系统-修改密码:
->nexus默认的管理员密码是**admin/admin123,为了安全起见,你可以修改管理员密码
->
->
2:nexus内置仓库介绍
3:索引
4:创建宿主仓库
5:将新创建的宿主仓库加入仓库组
6:创建新的nexus用户
3:上传jar到maven私服
1:修改maven仓库的settings.xml
1:配置server
<server>
<id>新创建的宿主仓库名</id>--->例如我创建的宿主仓库名
<username>新创建的用户名</username>-->例如我创建的是leyboy.nexus
<password>新创建用户密码</password>
</server>
2:创建maven映像
<mirror>
<id>nexusmirror</id>
<mirrorOf>central</mirrorOf>
<name>leyboy nexus mirror</name>
<url>http://softyuan.cn:9095/nexus/content/groups/public</url>
</mirror>
3:配置profile
<profile>
<id>leyboy.nexus</id> <!--新创建的宿主仓库名-->
<repositories>
<repository>
<id>leyboy.nexus</id><!--新创建的宿主仓库名-->
<url>http://softyuan.cn:9095/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
4:配置activeProfiles
<activeProfiles>
<activeProfile>leyboy.nexus</activeProfile><!--新创建的宿主仓库名-->
</activeProfiles>
5:配置具体的pom.xml(成功示例)
<?xml version="1.0" encoding="UTF-8"?>
<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>com.gitee.ley1996</groupId>
<artifactId>springboot-commons</artifactId>
<version>1.0.1</version>
<description>spring boot commons utility class</description>
<!--properties configuration-->
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.7</java.version>
</properties>
<!--配置repositories-->
<repositories>
<repository>
<id>leyboy.nexus</id>
<url>http://softyuan.cn:9095/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<distributionManagement>
<!--具体的repository-->
<repository>
<id>leyboy.nexus</id>
<url>http://softyuan.cn:9095/nexus/content/repositories/leyboy</url>
</repository>
</distributionManagement>
<dependencies>
</dependencies>
<developers>
<developer>
<name>刘恩源</name>
<email>[email protected]</email>
<url>https://gitee.com/ley1996/springboot-commons</url>
</developer>
</developers>
<scm>
<connection>scm:git:https://gitee.com/ley1996/springboot-commons.git</connection>
<developerConnection>scm:git:https://gitee.com/ley1996/springboot-commons.git</developerConnection>
<url>https://gitee.com/ley1996/springboot-commons</url>
</scm>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<configuration>
<attach>true</attach>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<defaultGoal>package</defaultGoal>
</build>
</project>