springBoot2.1.4版本里添加thymeleaf-extras-springsecurit

https://blog.csdn.net/wssc63262/article/details/86011939

頁面無法讀取到sec:authorize="isAnonymous()"和sec:authorize="isAuthenticated()"甚至sec標籤頁不做解析。

把thymeleaf-extras-springsecurity4改爲thymeleaf-extras-springsecurity5即可

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.thymeleaf.extras/thymeleaf-extras-springsecurity4 -->
        <dependency>
            <groupId>org.thymeleaf.extras</groupId>
            <artifactId>thymeleaf-extras-springsecurity5</artifactId>
        </dependency>
 /**定義認證規則*/
    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {

        //super.configure(auth);
        auth.inMemoryAuthentication()
                .withUser("admin").password(passwordEncoder().encode("admin")).roles("VIP1", "VIP2");

    }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章