【发布时间】:2018-01-28 18:30:15
【问题描述】:
我开发了一个 Spring mvc 应用程序,我想在其中读取一些属性值 来自位于 weblogic 服务器内部的属性文件。
已执行以下步骤:
在以下路径中创建了一个项目特定文件夹 appConfig:Oracle/Middleware/ORACLE_HOME/user_projects/domains/wl_server/config/rmsConfig
将名为 commonConfig.properties 的属性文件放在其中。
还使用以下条目编辑了setDomainEnv.cmd,
if NOT "%EXT_POST_CLASSPATH%"=="" (
set EXT_POST_CLASSPATH=%EXT_POST_CLASSPATH%;%DOMAIN_HOME%\config\appConfig
if NOT "%POST_CLASSPATH%"=="" (
set POST_CLASSPATH=%POST_CLASSPATH%;%EXT_POST_CLASSPATH%
) else (
set POST_CLASSPATH=%EXT_POST_CLASSPATH%
)
)
请在下面找到我的 Spring bean 配置文件:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.3.xsd">
<bean id="commonProps" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="commonConfig" />
<property name="cacheSeconds" value="120" />
</bean>
</beans>
在我的 Java Spring bean 类中,我这样引用它:
@Component
public class LocationClient{
@Autowired
private MessageSource commonProps;
public void showMessage(){
System.out.println(commonProps.getMessage("common.line", null, null, null));
}
}
现在commonProps 不是 null 而是在控制台中打印 null 的“common.line”。
请在下面找到属性文件条目:
common.line=382
任何人都有任何合适的解决方案???
【问题讨论】:
标签: java spring spring-mvc