maven deploy命令打包到私服

<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.zeelan.app</groupId>
    <artifactId>seller-auth</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <!-- 項目編碼 -->
    <properties> 
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
        <lombok.version>1.16.10</lombok.version>
        <mybatis.paginator.version>1.2.17.2</mybatis.paginator.version>
        <hibernate.validator.version>5.1.2.Final</hibernate.validator.version>
        <validation.api.version>1.1.0.Final</validation.api.version> 
    </properties>

    <!-- 遠程倉庫地址 -->
    <pluginRepositories>
        <pluginRepository>
            <id>nexus</id>
            <name>Team Nexus Repository</name>
            <url>http://192.168.0.126:8081/nexus/content/groups/public</url>
        </pluginRepository>
    </pluginRepositories>

    <!-- 配置遠程發佈到私服,mvn deploy -->
    <distributionManagement>
        <!-- 定義releases庫的座標 -->
        <repository>
            <id>releases</id>
            <name>Nexus Release Repository</name>
            <url>http://192.168.0.126:8081/nexus/content/repositories/releases/</url>
        </repository>
        <!-- 定義snapshots庫 -->
        <snapshotRepository>
            <id>snapshots</id>
            <name>Nexus Snapshot Repository</name>
            <url>http://192.168.0.126:8081/nexus/content/repositories/snapshots/</url>
        </snapshotRepository>
    </distributionManagement>

    <!-- 項目有依賴的全部jar座標配置 -->
    <dependencies>
        <!-- lombok jar -->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok.version}</version>
        </dependency>

        <!-- mybatis分頁插件jar -->
        <dependency>
            <groupId>com.github.miemiedev</groupId>
            <artifactId>mybatis-paginator</artifactId>
            <version>${mybatis.paginator.version}</version>
        </dependency>
        
        <!-- hibernate validator驗證jar -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>${hibernate.validator.version}</version>
        </dependency>
        <!-- hibernate validtor須要的依賴 jar -->
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>${validation.api.version}</version>
        </dependency>
    </dependencies>

    <build>
        <finalName>seller-auth</finalName>
        <!-- 插件庫聲明 -->
        <plugins>
            <!-- 配置運行環境JDK版本 -->
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </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>

            <!-- deploy時只上傳jar包到遠程倉庫的配置 -->
            <plugin>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.7</version>
                <executions>
                    <execution>
                        <id>default-deploy</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>deploy</goal>
                        </goals>
                        <!-- skip默認deploy插件的執行 -->
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </execution>
                    <execution>
                        <id>deploy-file</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>deploy-file</goal>
                        </goals>
                        <configuration>
                            <!-- 開發階段上傳到snapshot倉庫,上線階段上傳到release倉庫 -->
                            <repositoryId>${project.distributionManagement.snapshotRepository.id}</repositoryId>
                            <url>${project.distributionManagement.snapshotRepository.url}</url>
                            <file>${project.build.directory}/${project.artifactId}.jar</file>
                            <groupId>${project.groupId}</groupId>
                            <artifactId>${project.artifactId}</artifactId>
                            <version>${project.version}</version>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

 執行 mvn deploy就能打包到私服上了!java

mvn -clean配置清除插件,而後在執行命令能夠清除target下的文件git

mvn-clean package 本地打包,jar/war/等根據<packaging>jar/war</packaging>控制github

mvn -e 查看打包過程的錯誤信息apache

mvn -v查看mavne版本信息等等api

相關文章
相關標籤/搜索