How do I add Thymeleaf SpringSecurityDialect to spring boot

前端 未结 2 811
礼貌的吻别
礼貌的吻别 2021-01-13 01:03

In the configuration of my template engine I would like to add SpringSecurityDialect() like:

@Bean
public TemplateEngine templateEngine() {
    SpringTemplat         


        
2条回答
  •  一整个雨季
    2021-01-13 01:49

    It means that org.thymeleaf.extras:thymeleaf-extras-springsecurity4 has a dependency to org.thymeleaf:thymeleaf as you can see in the link to the repo above. Apparently you haven't provided this dependency. The class IExpressionEnhancingDialect is there. You can resolve that by adding the dependency to your project.

    Since this may get a bit complicated... I'm also playing around with Spring Boot, spring security and the security dialect for thymeleaf (plus spring data with h2). Here are my gradle dependencies for reference, they may help you somehow:

    ext['thymeleaf.version'] = '3.0.1.RELEASE'
    ext['thymeleaf-layout-dialect.version'] = '2.0.0'
    
    dependencies {
        compile("org.springframework.boot:spring-boot-devtools")
        compile("org.springframework.boot:spring-boot-starter-web")
        compile("org.springframework.boot:spring-boot-starter-thymeleaf")
        compile("org.springframework.boot:spring-boot-starter-data-jpa")
        compile("org.springframework.boot:spring-boot-starter-security")
        compile("org.thymeleaf.extras:thymeleaf-extras-springsecurity4:3.0.1.RELEASE")
    
        compile("com.h2database:h2")
    }
    

    Note that I want to use thymeleaf 3 instead of 2, that is why there are some extra unpleasant tweaks in my configuration.

    EDIT: The version of thymeleaf-extras-springsecurity4 should be the same as thymeleaf.version as suggested in the other answer.

提交回复
热议问题