The maven executable jar package

When the idea to create springboot projects, pom.xml file will automatically add the following plug-ins.

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

This plug packaging, and will generate two xxx.jar xxx.jar.original two packages. Xxx.jar which can be run independently.

Of course, we can also add some configure the plug-in.

   <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <!--重新打包-->
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <!--打包生成的jar包名称-->
        <finalName>test-demo</finalName>
    </build>

 

In maven project of the non-springboot, you can use the maven-assembly-plugin plugin will depend on the project have reached the jar

 <plugin>
      <artifactId>maven-assembly-plugin</artifactId>
      <configuration>
                <!--有主类时可以放开,并指明主类-->
                <!--<archive>-->
                        <!--<manifest>-->
                            <!--<mainClass>${exec.mainClass}</mainClass>-->
                        <!--</manifest>-->
                    <!--</archive>-->
              <descriptorRefs>
                   <descriptorRef>jar-with-dependencies</descriptorRef>
              </descriptorRefs>
       </configuration>
  </plugin>

 

Guess you like

Origin www.cnblogs.com/z-qinfeng/p/11716850.html