maven打包上传到本地中央库

pom文件中添加插件如下

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <testSource>${java.version}</testSource>
                    <testTarget>${java.version}</testTarget>
                </configuration>
            </plugin>
            <!--配置生成源码包-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>3.0.1</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <distributionManagement>
        <repository>
            <id>releases</id>
            <name>Nexus Release Repository</name>
            <url>http://xxxx:8081/repository/cetccd_hosted/</url>
        </repository>
        <snapshotRepository>
            <id>snapshots</id>
            <name>Nexus Snapshot Repository</name>
            <url>http://xxxx:8081/repository/cetccd_snapshots/</url>
        </snapshotRepository>
        </distributionManagement>
    

settings.xml文件添加如下内容

<server>
        <id>snapshots</id>
        <username>admin</username>
        <password>xxxx</password>
    </server>
    <server>   
        <id>releases</id>   
        <username>admin</username>   
        <password>xxxx</password>   
    </server> 

clean deploy -Dmaven.test.skip=true

原文地址:https://www.cnblogs.com/yuluoxingkong/p/9835709.html