我在使用嵌入式 tomcat 时遇到了问题:当我使用嵌入式 Tomcat 运行我的 Spring 应用程序时,似乎没有解析属性。
即使加载了属性文件:
INFO org.springframework.context.support.PropertySourcesPlaceholderConfigurer - Loading properties file from file [/home/julien/Documents/donnees/projets/Site-Rencontres/java/target/classes/META-INF/i18n/application.properties]
找不到资源包:
WARN org.springframework.context.support.ResourceBundleMessageSource - ResourceBundle [/META-INF/i18n/application] not found for MessageSource: Can't find bundle for base name /META-INF/i18n/application, locale fr
但是,当我从 Eclipse/STS 运行我的应用程序时,我没有这样的问题。
我部分解决了这个问题。通过删除此处的前导斜杠(在 Spring 配置中):
<property name="basenames" value="/META-INF/i18n/application,/META-INF/i18n/messages" />
要获得此信息,请执行以下操作:
<property name="basenames" value="META-INF/i18n/application,META-INF/i18n/messages" />
问题已解决。
然而,首先是什么导致了嵌入式Tomcat和标准Tomcat之间的行为差异,我没有解释......