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 carry out springboot+mybatis-plus+maven Multi-module injection

2025-03-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

How to carry out springboot+mybatis-plus+maven multi-module injection, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.

Mainly make use of the attribute scanBasePackages in springboot's annotation @ SpringBootApplication

Now there is a general module common with @ Service and other annotations. If you want to inject @ Service of common module under another module project, add @ SpringBootApplication (scanBasePackages = "com.example.**") to the startup class ProjectApplication in module project. Here the package name com.example.** requires that both modules contain com.example and wildcard characters are used with two * signs, so that you can use your own module annotation in project module.

In addition, our project uses mybatis-plus. In the mapper scan annotation in the configuration class of mybatis-plus, it is written as follows: @ MapperScan (value = "com.example.**.mapper"). I put the configuration class of mybatis-plus under the common module. Of course, I can also put it under the project module, but in the springboot multi-module mode, you need to write the configuration class of mybatis-plus under each module. According to this unified writing method, you can scan the mapper classes under both common and project modules at the same time.

In addition, change mybatis-plus.mapper-locations = classpath:/mapper/*Mapper.xml to mybatis-plus.mapper-locations = classpath*:/mapper/*Mapper.xml in the configuration

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

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

Internet Technology

Wechat

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

12
Report