Linux环境搭建maven私服Nexus

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环境
Linux环境搭建maven私服Nexus_第1张图片

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环境
Linux环境搭建maven私服Nexus_第2张图片

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,为了安全起见,你可以修改管理员密码
->这里写图片描述
->Linux环境搭建maven私服Nexus_第3张图片

2:nexus内置仓库介绍

Linux环境搭建maven私服Nexus_第4张图片

3:索引

Linux环境搭建maven私服Nexus_第5张图片

4:创建宿主仓库

Linux环境搭建maven私服Nexus_第6张图片
Linux环境搭建maven私服Nexus_第7张图片

5:将新创建的宿主仓库加入仓库组

Linux环境搭建maven私服Nexus_第8张图片

6:创建新的nexus用户

这里写图片描述

3:上传jar到maven私服

1:修改maven仓库的settings.xml

1:配置server
Linux环境搭建maven私服Nexus_第9张图片

新创建的宿主仓库名--->例如我创建的宿主仓库名
新创建的用户名-->例如我创建的是leyboy.nexus
新创建用户密码

2:创建maven映像

nexusmirror
central
leyboy nexus mirror
http://softyuan.cn:9095/nexus/content/groups/public

3:配置profile

leyboy.nexus


leyboy.nexus
http://softyuan.cn:9095/nexus/content/groups/public

true


true




4:配置activeProfiles

leyboy.nexus

5:配置具体的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.0modelVersion>

    <groupId>com.gitee.ley1996groupId>
    <artifactId>springboot-commonsartifactId>
    <version>1.0.1version>
    <description>spring boot commons utility classdescription>

    
    <properties>
        <project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8project.reporting.outputEncoding>
        <java.version>1.7java.version>
    properties>

    
    <repositories>
        <repository>
            <id>leyboy.nexusid>
            <url>http://softyuan.cn:9095/nexus/content/groups/publicurl>
            <releases>
                <enabled>trueenabled>
            releases>
            <snapshots>
                <enabled>trueenabled>
            snapshots>
        repository>
    repositories>

    <distributionManagement>
        
        <repository>
            <id>leyboy.nexusid>
            <url>http://softyuan.cn:9095/nexus/content/repositories/leyboyurl>
        repository>
    distributionManagement>


    <dependencies>

    dependencies>


    <developers>
        <developer>
            <name>刘恩源name>
            <email>[email protected]email>
            <url>https://gitee.com/ley1996/springboot-commonsurl>
        developer>
    developers>

    <scm>
        <connection>scm:git:https://gitee.com/ley1996/springboot-commons.gitconnection>
        <developerConnection>scm:git:https://gitee.com/ley1996/springboot-commons.gitdeveloperConnection>
        <url>https://gitee.com/ley1996/springboot-commonsurl>
    scm>


    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-source-pluginartifactId>
                <executions>
                    <execution>
                        <phase>packagephase>
                    execution>
                executions>
            plugin>
            <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-compiler-pluginartifactId>
                <configuration>
                    <source>${java.version}source>
                    <target>${java.version}target>
                configuration>
            plugin>
            <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-source-pluginartifactId>
                <configuration>
                    <attach>trueattach>
                configuration>
                <executions>
                    <execution>
                        <phase>compilephase>
                        <goals>
                            <goal>jargoal>
                        goals>
                    execution>
                executions>
            plugin>
        plugins>
        <defaultGoal>packagedefaultGoal>
    build>
project>

你可能感兴趣的:(linux,nexus,maven,jdk)