美文网首页
Maven3 构建可执行的单jar文件

Maven3 构建可执行的单jar文件

作者: MicoCube | 来源:发表于2018-05-23 09:50 被阅读0次
    • pom文件:
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>2.4.1</version>
                    <configuration>
                        <!-- get all project dependencies -->
                        <descriptorRefs>
                            <descriptorRef>jar-with-dependencies</descriptorRef>
                        </descriptorRefs>
                        <!-- MainClass in mainfest make a executable jar -->
                        <archive>
                            <manifest>
                                <mainClass>com.sinohuaxia.ua.Server</mainClass>
                            </manifest>
                        </archive>
    
                    </configuration>
                    <executions>
                        <execution>
                            <id>make-assembly</id>
                            <!-- bind to the packaging phase -->
                            <phase>package</phase>
                            <goals>
                                <goal>single</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
        </plugins>
        </build>
        <properties>
            <jdk.version>1.7</jdk.version>
            <project.build.sourceEncoding>
                UTF-8
            </project.build.sourceEncoding>
        </properties>
    
    • 千万不要把上面的plugiins放到</pluginManagement>标签里面,要不然白忙活了
    • mvn clean package 搞定

    相关文章

      网友评论

          本文标题:Maven3 构建可执行的单jar文件

          本文链接:https://www.haomeiwen.com/subject/spbjvxtx.html