我有一个带有国际化消息的 Spring Boot Thymeleaf Web 应用程序。默认翻译在我的messages.properties
文件中。
我application.yml
将指向MessageSourceAutoConfiguration
这些消息:
spring:
messages:
basename: locale/messages
当我运行该应用程序时,参数中的断点MessageSourceAutoConfiguration.setBasename()
被击中locale/messages
,并且一切正常。
现在我想使用 Zuul 设置将此应用程序用作反向代理,以将请求从浏览器传递到 REST 应用程序。
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
@SpringBootApplication
@EnableZuulProxy
public class ThymeleafApplication extends SpringBootServletInitializer {
...
}
所以我添加了一些配置到我的application.yml
:
zuul:
routes:
rest-api:
path: /rest-api/**
url: https://localhost:443/my-rest-api
我的build.gradle
样子是这样的:
dependencies {
compile 'org.springframework.boot:spring-boot-starter-thymeleaf'
compile 'org.springframework.cloud:spring-cloud-starter-zuul:1.0.4.RELEASE'
}
反向代理现在可以正常工作,但是国际化被破坏了。消息显示为“??page1.message1_en_GB??”。MessageSourceAutoConfiguration.setBasename()
不再触发断点。
如何设置 Zuul 以便我的 i18n 仍然可以工作?