我有一个 Spring Boot 应用程序,它使用 Thymeleaf 进行电子邮件模板。但我的应用程序不是 Web 应用程序。
但是,当包含 spring boot starter thymeleaf 依赖项时:
compile('org.springframework.boot:spring-boot-starter-thymeleaf')
Spring MVC 被传递地包含在我的类路径中,最终 Servlet.class 表明我的应用程序是一个 Web 应用程序...然后在 Tomcat servlet 容器中运行我的应用程序(默认在端口 8080 上)会产生不良结果。
如何在我的应用程序不作为 Web 应用程序运行的情况下使用 Spring Boot Thymeleaf 的功能(例如在 props 文件 ala https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html 中进行配置)?
最佳答案
按如下方式设置以下属性可防止 Spring Boot 应用程序作为 Web 应用程序运行:
spring.main.web-environment=false
关于spring - 通过不作为 Web 应用程序运行来使用 Spring Boot Thymeleaf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45225352/