Spring 云打破国际化消息
Spring Cloud breaks i18n messages
我有一个 spring 带有国际化消息的启动 Thymeleaf Web 应用程序。
默认翻译在我的 messages.properties
文件中。
我的 application.yml
将 MessageSourceAutoConfiguration
定向到这些消息:
spring:
messages:
basename: locale/messages
当我 运行 应用程序时,MessageSourceAutoConfiguration.setBasename()
中的断点被参数 locale/messages
击中,一切正常。
现在我想使用 Zuul 将此应用程序设置为 reverse proxy 以将请求从浏览器传递到 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 仍然有效?
好的,我已经通过升级到最新版本的 Spring Boot 1.3.1.RELEASE.
解决了这个问题
是a bug as pointed out in @nerdherd's answer to 。
我有一个 spring 带有国际化消息的启动 Thymeleaf Web 应用程序。
默认翻译在我的 messages.properties
文件中。
我的 application.yml
将 MessageSourceAutoConfiguration
定向到这些消息:
spring:
messages:
basename: locale/messages
当我 运行 应用程序时,MessageSourceAutoConfiguration.setBasename()
中的断点被参数 locale/messages
击中,一切正常。
现在我想使用 Zuul 将此应用程序设置为 reverse proxy 以将请求从浏览器传递到 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 仍然有效?
好的,我已经通过升级到最新版本的 Spring Boot 1.3.1.RELEASE.
解决了这个问题是a bug as pointed out in @nerdherd's answer to