【问题标题】:How to have both Velocity and Thymeleaf in the same project but have controllers using only one of them如何在同一个项目中同时拥有 Velocity 和 Thymeleaf 但控制器只使用其中一个
【发布时间】:2015-09-20 02:10:22
【问题描述】:

我正在使用带有 2 个单独模板引擎的 Spring Boot:

Thymeleaf:用于 HTML 渲染
Velocity:用于电子邮件格式

即使我收到在我的日志中提到缺少速度模板的错误(而我实际上使用的是 Thymeleaf 模板),该应用程序仍能顺利运行。

Eg : ResourceManager : unable to find resource 'information-inquiry.vm' in any resource loader.

我的问题是找出是否可以同时插入两个引擎,但禁止速度尝试从我的控制器渲染模板。

【问题讨论】:

    标签: spring-boot velocity thymeleaf


    【解决方案1】:

    将属性 spring.velocity.enabled 设置为 false 应该可以完成这项工作 - 它会禁用 VelocityViewResolver 的创建,但会保留所有其他与 Velocity 相关的 bean。

    当您尝试了解如何修改默认 Spring Boot 行为时,我建议您检查 Spring Boot 源并查找 *AutoConfiguration 类,在本例中为 org.springframework.boot.autoconfigure.velocity.VelocityAutoConfiguration

    【讨论】:

      猜你喜欢
      • 2022-01-25
      • 2017-01-05
      • 2023-03-11
      • 2017-02-14
      • 1970-01-01
      • 2012-07-18
      • 2018-06-29
      • 2011-08-02
      • 2015-08-24
      相关资源
      最近更新 更多