Controller cannot be resolved with @Autowired after using Shiro

Just learning Shiro, and then want to integrate him into spring MVC.

I've been doing it for a long time, but I haven't been able to annotate it with @Autowired

In the end, I found that annotations are only available in the Controller. I checked a lot of information, but I didn't fully understand it. Finally, I suddenly found that after referring to Shiro, the Controller layer cannot use the bean of the entity class, and must be implemented through the interface.

For example: My previous UserService was directly a class, and then annotated with @Service, this will not work

You must first write a UserService interface, and then write a UserServiceImpl to integrate the UserService interface

Then, my Controller can @Autowired UserService

embarrassment

Guess you like

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