【发布时间】:2014-01-29 14:44:55
【问题描述】:
这是我试图从 My.properties 文件中读取“ TestMe 变量的代码。
public class TestToCheckProperties {
private int testMe;
public void setTestMe(int testMe) {
this.testMe = testMe;
}
public static void main(String args[]){
ApplicationContext context = new ClassPathXmlApplicationContext("classpath:/META-INF/spring/bean/dfp-web-beans.xml");
TestToCheckProperties testToCheckProperties=context.getBean(TestToCheckProperties);
System.out.println("testMe: "+testToCheckProperties.testMe);
}
这是在我的 Spring.XML 中 我为 TestToCheckProperties 类创建了一个 bean:
<bean id='TestToCheckProperties' class="com.My.Code.TestToCheckProperties" >
<property name="testMe" value="${My.code.TestToCheckProperties}" />
</bean>
这是在我的 My.Property 文件中,我正在尝试在我的班级中读取此值:
#TestToCheckProperties
My.code.TestToCheckProperties=10
这是我遇到的错误
【问题讨论】:
-
您在写完问题之前发帖了吗?你的错误在哪里?发布其余的上下文配置。
标签: java spring properties