1 .Problem background
Split springboot into multi module projects (split in different forms)
Split by hierarchy: one item for controller, one item for service, and one item for Dao (mapper).
Split by business: a business module is split into one project (including the controller, service, Dao, etc. of the business)
After the split is completed, start the original application and prompt application failed to start
2 .Problem phenomenon
Description:
Field userMapper in com.fanzyx.crane.framework.security.service.JwtUserDetailsService required a bean of type ‘com. fanzyx.xx.mapper.XxxrMapper’ that could not be found.
The injection point has the following annotations:
– @org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean of type ‘com.fanzyx.xx.mapper.XxxrMapper’ in your configuration.
Or prompt that a method (the method you called) in the basemapper of mybatis plus cannot be found
3. Cause of problem
Check whether the next package reference conflicts. If there are no conflicts, see the following
If the basic package path of mapper scanning is not configured in the application, it will only be found under the current module
e.g.
@SpringBootApplication()
public class XxxApplication {
public static void main(String[] args) {
SpringApplication.run(XxxApplication.class,args);
}
}
4. Solution
Add annotation on xxxapplication (startup class) and add scanning basic path
// Multi-module projects need to be configured to scan base packages, otherwise they will not be able to load classes from other modules
@SpringBootApplication(scanBasePackages = {"com.fanzyx.xx"})
// must be configured to a specific path, the middle ** can match multiple levels of directories, one * can only match a single level of directories
//@MapperScan(basePackages = {"com.fanzyx.xx.**.mapper"})
public class XxxApplication{
public static void main(String[] args) {
SpringApplication.run(XxxApplication.class,args);
}
}
Similar Posts:
- Springboot + Maven multi module project startup Error: XxxService cannot be found
- Container Cannot Find bean, Field usersMapper in com.imooc.impl.UserServiceImpl required a bean of type ‘com.imooc.mapper.UsersMapper’ that could not be found.
- SpringBoot Frame: Failed to determine a suitable driver class [How to Solve]
- Two ways to implement Spring Boot’s scanmapper interface class
- [leetcode] 140. Word break II word split II
- Solving the problem of nginx reverse proxy web service soap:address location problem
- [Solved] Springboot Error: invalid bound statement (not found)
- Spring cloud uses feignclient to start and report an error
- [Two Solutions] non-static method xxx() cannot be referenced from a static context
- [Solved] Mybatis Error: Invalid bound statement (not found)