nexus搭建私服后的本地配置

maven私服安装过程略过,网上都有,这里只简单记录下项目的配置过程

本地配置

前提:在私服中已经创建了仓库(这里假设仓库名test-release) 以及新建了User账号

本地maven配置

修改setting.xml文件,添加私服的账号密码

<servers>
    <server>
        <!-- 这个id跟项目pom文件里的id对应上就行 -->
        <id>theID</id>
        <!-- 私服创建的用户名 -->
        <username>youUserName</username>
        <!-- 私服创建的用户名对应的密码 -->
        <password>youPassword</password>
    </server>
</servers>

项目中配置

在pom文件中添加:

<?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.package</groupId>
    <artifactId>test-springboot</artifactId>
    <version>1.0-RELEASE</version>
    <!--注意限定版本一定为RELEASE,因为上传的对应仓库的存储类型为RELEASE -->
    <!--指定仓库地址 -->
    <distributionManagement>
        <repository>
            <!--此名称要和.m2/settings.xml中设置的ID一致 -->
            <id>theID</id>
            <url>http://yourhost:port/repository/test-release/</url>
        </repository>
    </distributionManagement>

    <build>
        <plugins>
            <!--发布代码Jar插件 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.7</version>
            </plugin>
            <!--发布源码插件 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.2.1</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>


</project>

发布jar包

项目路径下的命令行执行(IDEA自带命令行,可以直接在底部菜单的Terminal里执行)

mvn deploy

命令解释可参考
https://www.cnblogs.com/codeclock/p/12106519.html

猜你喜欢

转载自www.cnblogs.com/codeclock/p/12433547.html
今日推荐