Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the record of springboot multi-module packaging?

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces how the record of springboot multi-module packaging is, the content is very detailed, interested friends can use it for reference, I hope it can be helpful to you.

The project structure is as follows:

The pom.xml files for each project are as follows

Parent project

4.0.0 common controller domain com.hs demo 0.0.1-SNAPSHOT spring-modules pom Demo project for Spring Boot 1.8 UTF-8 2.4.2 true true org.springframework.boot spring-boot-starter-test test Org.springframework.boot spring-boot-dependencies 2.4.4 pom import Org.springframework.boot spring-boot-maven-plugin repackage Org.apache.maven.plugins maven-compiler-plugin 3.7.0 ${java.version} ${java.version} ${project.build.sourceEncoding} Org.apache.maven.plugins maven-surefire-plugin 2.19.1 ${maven.test.skip} ${maven.test.failure.ignore}

Controller subproject (main project)

Demo com.hs 0.0.1-SNAPSHOT 4.0.0 controller jar org.springframework.boot spring-boot-starter org.springframework.boot spring-boot-starter-web mysql mysql-connector-java Mysql mysql-connector-java com.hs domain 0.0.1-SNAPSHOT com.hs common 0.0.1-SNAPSHOT

Domain subproject (model and service, repository)

Demo com.hs 0.0.1-SNAPSHOT 4.0.0 domain org.springframework.boot spring-boot-starter-data-jpa com.hs common 0.0.1-SNAPSHOT

Common subproject (public class project)

Demo com.hs 0.0.1-SNAPSHOT 4.0.0 common

The test begins below. Currently, spring-boot-maven-plugin is on the parent pom file. The main class file cannot be found in error after execution: Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.4.4:repackage (default) on project common: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:2.4.4:repackage failed: Unable to find main class

Follow the prompts to add the configuration of main class to the parent pom.xml

Org.springframework.boot spring-boot-maven-plugin com.hs.demo.DemoApplication ZIP repackage

This will report four errors, all of which do not exist in the package.

Continue testing and put spring-boot-maven-plugin into the pom of the main project

The final pom.xml of the controller project is as follows:

Demo com.hs 0.0.1-SNAPSHOT 4.0.0 controller jar org.springframework.boot spring-boot-starter org.springframework.boot spring-boot-starter-web mysql mysql-connector-java Mysql mysql-connector-java com.hs domain 0.0.1-SNAPSHOT com.hs common 0.0.1-SNAPSHOT org.springframework.boot spring- Boot-maven-plugin repackage

Continue the test. The package is successful and the file size is normal.

What is the use of this repackage? I tried it, and it turned out like this.

Org.springframework.boot spring-boot-maven-plugin

The package is also successful, except that there is a problem with the jar size of the main project, only 4kb

Take a look at the official website's explanation of this: https://docs.spring.io/spring-boot/docs/2.4.4/maven-plugin/reference/htmlsingle/#repackage-example-exclude-dependency

This is actually typing in all dependent jar packages.

On the springboot multi-module packaging record is shared here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report