首页 > 代码库 > maven打包jar源码至私服

maven打包jar源码至私服

1. setting文件 配置私服中设置的用户和密码

 <servers>
        <server>
            <id>releases</id>  
            <username>admin</username>  
            <password>xxxxxxxxxxx</password>  
        </server>
        <server>
            <id>snapshots</id>  
            <username>admin</username>  
            <password>xxxxxxxxx</password>  
       </server>  
       <server>
            <id>Nexus</id>  
            <username>admin</username>  
            <password>xxxxxxx</password>  
       </server>  
       <server>
            <id>Nexus2</id>  
            <username>admin</username>  
            <password>xxxxxxx</password>  
       </server>

2.需要打包的项目的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">
    <version>1.1.0</version>
    <modelVersion>4.0.0</modelVersion>
    <packaging>jar</packaging>
    <artifactId>msg-service</artifactId>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.plugin.version>3.2</maven.compiler.plugin.version>
        <maven_jar_plugin_version>2.4</maven_jar_plugin_version>
    </properties>

    <dependencies>
       
        <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-dependency-plugin -->
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>3.0.1</version>
        </dependency>

    </dependencies>

    <distributionManagement>
        <repository>
            <id>releases</id>
            <name>Maven Snapshots</name>
            <url>http://192.168.79.16:9081/nexus/content/repositories/releases</url>
        </repository>
        <snapshotRepository>
            <id>snapshots</id>
            <name>Maven Snapshots</name>
            <url>http://192.168.79.16:9081/nexus/content/repositories/snapshots</url>
        </snapshotRepository>
    </distributionManagement>

    <build>
        <finalName>msg-service</finalName>
        <sourceDirectory>src/main/java/com/fqgj/jkzj/msg/service</sourceDirectory>
        <!--<resources>-->
        <!--&lt;!&ndash; 控制资源文件的拷贝 &ndash;&gt;-->
        <!--<resource>-->
        <!--<directory>...</directory>-->
        <!--</resource>-->
        <!--</resources>-->

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.plugin.version}</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <inherited>true</inherited>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19.1</version>
                <configuration>
                    <skip>true</skip><!-- 跳过测试 -->
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>${maven_jar_plugin_version}</version>
                <configuration>
                    <archive>
                        <addMavenDescriptor>true</addMavenDescriptor>
                        <index>true</index>
                        <manifest>
                            <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <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>
        </plugins>
    </build>
</project>

 

maven打包jar源码至私服