未添加模板引擎@RequestMapping無(wú)法顯示Html頁(yè)面(404錯(cuò)誤)
新建的Springboot項(xiàng)目pom.xml
<!---至少要添加一個(gè)模板引擎,要不然@RequestMapping無(wú)法顯示Html頁(yè)面(404錯(cuò)誤)->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
Springboot整合Shiro安全驗(yàn)證框架導(dǎo)致@Service 注入失敗
public class ShiroRealmWrapper extends AuthorizingRealm {
@Autowired
public UserInfoService userInfoService;// null
....
}
折騰了半宿,看到有網(wǎng)友已經(jīng)提前采坑:Shiro解決無(wú)法注入Service問(wèn)題
按照這個(gè)網(wǎng)友的說(shuō)法
對(duì)于SpringMVC框架:ShiroRelam屬于filter即過(guò)濾器,它在Spring未完成注入bean之前就已經(jīng)攔截了,因此無(wú)法注入。
對(duì)于SpringBoot,沒有將ShiroRealm注入Bean。
ShiroConfig在注入SecurityManager時(shí)setRealm()的參數(shù)ShiroRealm不能自己new出來(lái),而要先將其注入Bean