2017-07-20 58 views
1

我有一個使用Thymeleaf進行電子郵件模板的Spring Boot應用程序。雖然我的應用程序不是一個Web應用程序。使用Spring Boot Thymeleaf不作爲Web應用運行

然而,包括彈簧開機啓動thymeleaf依賴時:

compile('org.springframework.boot:spring-boot-starter-thymeleaf')

Spring MVC中的及物包括最終Servlet.class在我的類路徑的信號,我的應用程序是一個Web應用程序......這然後在Tomcat servlet容器中運行我的應用程序(默認情況下在端口8080上)會有不良結果。

如何在沒有我的應用程序作爲Web應用程序運行的情況下使用Spring Boot Thymeleaf的功能(例如配置在道具文件ala https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html中)?

+0

發佈一個解決方案,但有可能是一個更好的選擇,諸如包括Thymeleaf依賴,不引進其他不需要的依賴項(例如Spring Web MVC)仍然允許通過props文件配置Thymeleaf。將標記爲更好的選擇作爲答案。 – James

+1

從Spring Boot 2.0開始,Thymeleaf初學者不會再傳遞MVC。 –

回答

2

設置以下屬性如下​​防止春季啓動應用程序運行的Web應用程序:

spring.main.web-environment=false

相關問題