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

How to add a new module to a multi-module project by springboot

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces how to add a new module to the multi-module project of springboot, which has certain reference value. Interested friends can refer to it. I hope you will have a lot of gains after reading this article. Let Xiaobian take you to understand it together.

springboot Multi-module project adds a new module

Select Maven Module and fill in the module name

If blank, catalog directory can select internal

Change package name

New modules are automatically added to the parent pom after completion

Manually add the dependency of the new module

(Similar to manually adding modules)

Springboot How to add a new module

In the springboot project framework, a project is divided into two modules, the main project and the test project, and our test project can be divided according to the function, such as unit test, integration test, business test and so on.

For a beginner, the way to establish modules needs to be mastered by us. There is not much information on the Internet. It is rarely mentioned that this function point is popular here.

The basic structure of the springboot project is shown in the figure

Let's build an integration test module intTest. Some teams like to call it intTest. It can be. The name intTest comes from the official documentation of gradle. I also learn from it (https://docs.gradle.org/current/userguide/java_testing.html#test_reporting).

Select File->Project Structure File-> Project Structure

We see two default modules

Second, close it and then left-click on the test module to select Copy

Select Paste on src and enter the new module name

3. Select files to copy

And then you don't have to choose here, you can go and re-establish it yourself.

If the software has bugs

You can still copy the current project file to the new module, then you delete it, and then restore the package, after which your intTest package appears, when the restore is not successful, it is just a folder!

5. Open the file structure window

intTest can be in a group without main,test, you can move to the same group

Add java folder to root project

After creating a folder, you need to modify the folder type, as shown in the figure:

You can configure the intTest module for its related information, also in build.gradle, this will not be described in detail

Now you know how to build a multi-module application in springboot!

Note:

When you add a new module, if you want to integrate the previous module, you can add the following code to build.gradle (for example, the new module is integTest)

integTestCompile sourceSets.main.outputintegTestCompile configurations.testCompileintegTestCompile sourceSets.test.outputintegTestRuntime configurations.testRuntime

This way, after refreshing, its dependencies will inherit the two modules main and test.

Thank you for reading this article carefully. I hope that the article "springboot how to add a new module to a multi-module project" shared by Xiaobian will be helpful to everyone. At the same time, I hope that everyone will support you a lot and pay attention to the industry information channel. More relevant knowledge is waiting for you to learn!

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