小编Gui*_*ost的帖子

Spring Boot Security + Thymeleaf:缺少IProcessorDialect类

我正在尝试将Thymeleaf安全方言(例如sec:authorize标签)集成到正常工作的Spring Boot + Spring Security应用程序中.

经过一些研究后,我发现激活它的解决方案是:

在POM文件中添加依赖项:

<dependency>
    <groupId>org.thymeleaf.extras</groupId>
    <artifactId>thymeleaf-extras-springsecurity4</artifactId>
    <version>3.0.0.RELEASE</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

并在模板文件的顶部包含标记:

<html   xmlns:th="http://www.thymeleaf.org" lang="en"
        xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
Run Code Online (Sandbox Code Playgroud)

到现在为止还挺好.找到依赖关系,标记中标记的标记.

但是,它们不会被考虑在内并出现在生成的最终HTML中.

由于Spring Boot自动配置中的一个问题没有启用,似乎有必要手动将SpringSecurityDialect Bean 添加到一个@Configuration类来启用它(StackOverflow上的几个问题已经解决了):

@Bean
    public SpringSecurityDialect securityDialect() {
        return new SpringSecurityDialect();
    }
Run Code Online (Sandbox Code Playgroud)

这就是导致问题的原因:当我将这个Bean添加到我的Spring Boot配置中时,它会引发异常,因为它找不到类org.thymeleaf.dialect.IProcessorDialect.这是错误:

> java.lang.IllegalStateException: Could not evaluate condition on
> org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration#propertySourcesPlaceholderConfigurer
> due to org/thymeleaf/dialect/IProcessorDialect not found. Make sure
> your own configuration does not rely on that class. This can also
> happen if you are @ComponentScanning a springframework package (e.g.
> …
Run Code Online (Sandbox Code Playgroud)

java spring spring-security thymeleaf spring-boot

20
推荐指数
1
解决办法
6648
查看次数

标签 统计

java ×1

spring ×1

spring-boot ×1

spring-security ×1

thymeleaf ×1