springboot learning series: the method of packaging the project in a common way

Scenes

Develop a new project, because there are some similarities in functions, it is set as the project's public dependency project, which stores the code of the common part. Because of the introduction of the service-parent framework of the company's microservice framework, the default build method is springboot packaging, so that the packaged project cannot be imported by other projects. Therefore, this blog mainly describes the solution to this situation.

surroundings

software version
spring-boot 2.1.1.RELEASE

text

spring-boot-maven-plugin plugin command

In the packaging process, we mainly used the spring-boot-maven-plugin plug-in, so the following table is the meaning of the commands used by the plug-in.

command Description
spring-boot:repackage The default goal. After mvn package, package the executable jar/war again,
and rename the package generated by mvn package to *.original
spring-boot:run Run Spring Boot application
spring-boot:start In the mvn integration-test stage, manage the life cycle of Spring Boot applications
spring-boot:stop In the mvn integration-test stage, manage the life cycle of Spring Boot applications
spring-boot:build-info Generate the build information file build-info.properties used by Actuator

Solution

Command line settings

When the compiler package, add -Dspring-boot.repackage.skip=trueparameters to, the following examples:

mvn clean package -Dspring-boot.repackage.skip=true

This method is convenient and fast, suitable for single use.

maven file settings

If you don't want to be so troublesome, just set it directly inside the plug-in, as follows

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <skip>true</skip>
    </configuration>
</plugin>

After configuration, run to generate ordinary lib package.

to sum up

Only by thinking and summarizing the problems encountered at work can you form your own solutions.

Ask for praise

If my article is helpful to everyone, you can click like or favorite at the bottom of the article;
if there is a good discussion, you can leave a message;
if you want to continue to view my future articles, you can click Follow
You can scan the following QR code to follow me 'S public account: Fengye Zhixuege, check out my latest share!
Insert picture description here
Bye bye

Guess you like

Origin blog.csdn.net/u013084266/article/details/108882931