解决SpringBoot项目@Autowired注入bean失败的问题

it2022-05-05  169

 错误信息如下:

*************************** APPLICATION FAILED TO START *************************** Description: Field personMapper in com.jymescloud.knmes.service.impl.PersonServiceImpl required a bean of type 'com.jymescloud.knmes.mapper.auto.PersonMapper' 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.jymescloud.knmes.mapper.auto.PersonMapper' in your configuration.

经排查发现错误是因为没有配置mapper包的扫描导致的,解决办法是在SpringBoot启动类上添加注解@MapperScan(包地址)


最新回复(0)