我正在学习Java Spring,在使用属性文件时遇到了问题。未在xml文件中读取属性文件值并抛出异常。
XML文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="triangle1" class="com.springtest.shapes.Triangle">
<property name="pointA" ref="zeroPoint"/>
<property name="pointB" ref="point2" />
<property name="pointC" ref="point3" />
</bean>
<bean id="zeroPoint" class="com.springtest.shapes.Point">
<property name="x" value="#{pointA.pointX}" />
<property name="y" value="#{pointA.pointY}" />
</bean>
<bean id="point2" class="com.springtest.shapes.Point">
<property name="x" value="5" />
<property name="y" value="2" />
</bean>
<bean id="point3" class="com.springtest.shapes.Point">
<property name="x" value="-20" />
<property name="y" value="10" />
</bean>
<bean class="com.springtest.main.DisplayNameBeanPostProcessor"/>
<bean class="org.SpringFramework.beans.factory.config.PropertyPlaceHolderConfigurer">
<property name="locations">
<value>classpath:pointconfig.properties</value>
</property>
</bean>
</beans>
&#13;
属性文件如下:
pointA.pointX=0
pointA.pointY=0
&#13;
显示以下异常:
Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1008E: Property or field 'pointA' cannot be found on object of type 'org.springframework.beans.factory.config.BeanExpressionContext' - maybe not public?
at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:213)
at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:100)
at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:87)
at org.springframework.expression.spel.ast.CompoundExpression.getValueRef(CompoundExpression.java:52)
at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:88)
at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:111)
at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:270)
at org.springframework.context.expression.StandardBeanExpressionResolver.evaluate(StandardBeanExpressionResolver.java:163)
... 28 more
提前致谢