I. Introduction:
The project was built using springboot automatic injection, but an error was reported when it started! ! ! , The error is as shown below:
Description: Field userEntityMapper in com.xxx.xxx.service.UserService required a bean of type'com.xxx.xxx.dao.UserEntityMapper' that could not be found. Action: Consider defining a bean of type'com.xxx.xxx .dao.UserEntityMapper' in your configuration.
2. Solution:
1. Check whether the annotations you wrote are wrong, and not.
2. Find solutions on the Internet: as follows:
step one:
Add in the configuration file of springboot, the configuration of mybatis is as follows:
mybatis: typeAliasesPackage: com.xxx.xxx.dao.entity mapperLocations: classpath:mapper/*.xml
Step two:
① Put the interface and the corresponding implementation class in the same directory or its subdirectory as the application startup class , so that the annotations can be scanned, which is the most trouble-free way. (Not tested)
② Or add @MapperScan or @ComponentScan annotations to the startup class , and manually specify the annotations under which packages the application class should scan, as shown below:
@SpringBootApplication @ComponentScan(basePackages = {"com.xxx.xxx.dao"})
③Or add @Mapper annotation on the interface .
@Mapper public interface UserMapper { }
ps: The reason why the corresponding Bean was not found is because @SpringBootApplication did not scan it.
Read More:
- [Solved] “Field pet in XXX.HelloController required a bean of type ‘XXX.Pet‘ that could not be found.“
- [Solved] Error getting bean using springboot: no qualifying bean of type ‘xxx’ available
- [Solved] Springboot Error creating bean with name ‘dataSource’ defined in class path resource
- Tk.mapper Common mapper Error: Error creating bean with name ‘commonMapper‘ defined in file xxx
- [Solved] Springboot Project Startup Error: Error running XXX. Command line is too long.
- [Solved] UnsatisfiedDependencyException: Error creating bean with name
- [Solved] nacos Startup Error: Error creating bean with name ‘authFilterRegistration‘ defined in class path resource
- SpringBoot startup error Failed to determine a suitable driver class
- SpringBoot Access Clickhouse Error: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘jdbcConverter’ defined in class path resource [***.class]
- How to Solve SpringBoot MongoDB MongoAutoConfiguration Startup Error
- [Solved] SpringBoot Project Start Error: No bean named ‘org.springframework.context.xxxxx.importRegistry‘ available
- [Solved] SpringBoot Error: HttpMediaTypeNotSupportedException: Content type ‘application/json‘ not supported
- [Solved] Swagger Startup Error: Failed to start bean ‘documentationPluginsBootstrapper‘
- How to Solve Error: Missing type map configuration or unsupported mapping
- [Solved] SpringBoot Integrates Swagge Error: Failed to start bean ‘documentationPluginsBootstrapper‘
- [Solved] Springboot Project Startup Error: Error starting ApplicationContext
- SpringBoot High Version Import Swagger 2.9.2 Error: ApplicationContextException: Failed to start bean ‘documentationPluginsBootstrapper‘
- [Solved] ibatis.builder.BuilderException: Error parsing Mapper XML: Could not resolve type alias ‘XXX‘
- SpringBoot IntegratenRedis Annotations and access error: EL1008E: Property or field ‘getListMember‘ cannot be found on object of type
- [Solved] renren-fast Startup Error: Error creating bean with name ‘scheduleJobController‘
thank you…
i tried to solve this problem for two days….