Maven 私服 搭建

1.nexus下载

下载地址:https://www.sonatype.com/download-oss-sonatype

2.安装nexus服务

nexus.exe /install <optional-service-name>  //安装nexus服务

3.启动和关闭nexus服务

#启动
net start nexus
#关闭
net stop nexus

4.进入管理界面

默认端口为8081,浏览器访问:127.0.0.1:8081

登录账号:admin

默认密码:admin123

5.仓库类型

6.创建宿主仓库

6.添加用户

7.maven配置文件setting.xml

servers节点添加 id 和私服账号

<servers>
    <server>
        <id>maven-test-releases</id>
        <username>ke****yu</username>
        <password>keke0123</password>
    </server>
	<server>
        <id>maven-test-snapshot</id>
        <username>ke****yu</username>
        <password>keke0123</password>
    </server>
</servers>
<mirrors>
    <mirror>
        <id>maven-test-releases</id>
        <mirrorOf>*</mirrorOf>
        <name>maven-test-releases</name>
        <url>http://127.0.0.1:8081/repository/maven-test-release/</url>
    </mirror>
	<mirror>
        <id>maven-test-snapshot</id>
        <mirrorOf>*</mirrorOf>
        <name>maven-test-snapshot</name>
        <url>http://127.0.0.1:8081/repository/maven-test-snapshot/</url>
    </mirror>

	<mirror>
        <id>alimaven</id>
        <mirrorOf>central</mirrorOf>
        <name>aliyun maven</name>
        <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
    </mirror>
	 <!-- 中央仓库1 -->
    <mirror>
        <id>repo1</id>
        <mirrorOf>central</mirrorOf>
        <name>Human Readable Name for this Mirror.</name>
        <url>http://repo1.maven.org/maven2/</url>
    </mirror>

        <!-- 中央仓库2 -->
    <mirror>
        <id>repo2</id>
        <mirrorOf>central</mirrorOf>
        <name>Human Readable Name for this Mirror.</name>
        <url>http://repo2.maven.org/maven2/</url>
    </mirror>
</mirrors>

8.项目文件pom.xml

    <distributionManagement>
        <repository>
            <id>maven-test-releases</id>
            <name>maven-test-releases</name>
            <url>http://127.0.0.1:8081/repository/maven-test-release/</url>
        </repository>
        <snapshotRepository>
            <id>maven-test-snapshot</id>
            <name>maven-test-snapshot</name>
            <url>http://127.0.0.1:8081/repository/maven-test-snapshot/</url>
        </snapshotRepository>
    </distributionManagement>

9.测试依赖

10.导入依赖

其他项目选用之前maven配置文件setting.xml,导入依赖:

        <dependency>
            <groupId>com.example</groupId>
            <artifactId>dubbo</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>

11.上传源码到Maven私服

            <!-- 要将源码放上去,需要加入这个插件 -->
            <plugin>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <attach>true</attach>
                </configuration>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值