Java spring“”是否支持“{myprops['abc']}”表达式?
我定义了一个属性持有者:Java spring“”是否支持“{myprops['abc']}”表达式?,java,spring,Java,Spring,我定义了一个属性持有者: <util:properties id="myProps" location="file:my.properties" /> 但是当我定义这个bean时: <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" r
<util:properties id="myProps" location="file:my.properties" />
但是当我定义这个bean时:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="myDataSource"/>
<property name="packagesToScan" value="test.domain"/>
<property name="hibernateProperties">
<props>
<prop key="hibernate.show_sql">#{ myProps['db.timeout']}</prop>
</props>
</property>
</bean>
是否支持{}表达式?如何解决这个问题
感谢subhashis的回答,但我忘了提到,由于一些设计限制,我不能在项目中使用org.springframework.beans.factory.config.propertyPlaceHolderConfiger。是的,它支持表达式,但没有使用use$,请参见下面的示例
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>database.properties</value>
</property>
</bean>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
抱歉,我忘了提及由于一些设计限制,我无法在项目中使用PropertyPlaceHolderConfigure
Can't resolve symbol: #{ myProps['db.timeout']}
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>database.properties</value>
</property>
</bean>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>