如何将 Thymeleaf SpringSecurityDialect 添加到 spring boot [英] How do I add Thymeleaf SpringSecurityDialect to spring boot

查看:35
本文介绍了如何将 Thymeleaf SpringSecurityDialect 添加到 spring boot的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的模板引擎的配置中,我想添加 SpringSecurityDialect() 如下:

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

@Bean
public TemplateEngine templateEngine() {
    SpringTemplateEngine engine = new SpringTemplateEngine();
    engine.addDialect(new SpringSecurityDialect());
    engine.setEnableSpringELCompiler(true);
    engine.setTemplateResolver(templateResolver());
    return engine;
}

但是 eclipse 告诉我:

However eclipse is telling me:

无法解析 org.thymeleaf.dialect.IExpressionEnhancingDialect 类型.它是从所需的 .class 文件间接引用的

The type org.thymeleaf.dialect.IExpressionEnhancingDialect cannot be resolved. It is indirectly referenced from required .class files

这是什么意思,我该如何解决?

What does this mean and how can I fix it?

pom.xml 我有:

<dependency>
    <groupId>org.thymeleaf.extras</groupId>
    <artifactId>thymeleaf-extras-springsecurity4</artifactId>
</dependency>

推荐答案

这意味着 org.thymeleaf.extras:thymeleaf-extras-springsecurity4 依赖于 org.thymeleaf:thymeleaf可以在上面的回购链接中看到.显然你还没有提供这种依赖.IExpressionEnhancingDialect 类就在那里.您可以通过向项目添加依赖项来解决该问题.

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.

因为这可能会变得有点复杂......我也在玩 Spring Boot、spring security 和 thymeleaf 的安全方言(加上带有 h2 的 spring 数据).这是我的 gradle 依赖项以供参考,它们可能会以某种方式帮助您:

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")
}

请注意,我想使用 thymeleaf 3 而不是 2,这就是为什么我的配置中有一些额外的令人不快的调整.

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

thymeleaf-extras-springsecurity4 的版本应该与另一个答案中建议的 thymeleaf.version 相同.

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

这篇关于如何将 Thymeleaf SpringSecurityDialect 添加到 spring boot的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆