myrealm专题

SpingBoot集成shiro,MyRealm中无法@Autowired注入Service的问题

网上说了很多诸如是Spring加载顺序,shiroFilter在Spring自动装配bean之前的问题,其实也有可能忽略如下低级错误。 在ShiroConfiguration中要使用@Bean在ApplicationContext注入MyRealm,不能直接new对象。 道理和Controller中调用Service一样,都要是SpringBean,不能自己new。 错误方式: @Bean