Spring Boot @Autowired cannot inject class Consider defining a bean of type

The default rule of SpringBoot equipment is to scan from top to bottom according to the package location where the Application class is located.

E.g

com.seed.controller
com.seed.service
com.seed.dao

If the Application is under the package com.seed.controller, it will not be able to scan the service dao, so you can see that the spring integration mybatis written by many blogs is under one package.

If you put Application under com.seed, you can scan its sub-package service dao


Stuck me for 3 hours on this little issue. . . Oops. . . I hope that all the technical gurus friends must try it out when they write blogs. Tell everyone about the pitfalls.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325122234&siteId=291194637