Java 为什么是春天<;util:properties>;不起作用

Java 为什么是春天<;util:properties>;不起作用,java,spring,spring-mvc,Java,Spring,Spring Mvc,我是春天的新手,现在正在尝试与数据库建立连接。 我配置了jdbc-config.xml: <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:aop="http://www.springframe

我是春天的新手,现在正在尝试与数据库建立连接。 我配置了jdbc-config.xml:

<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:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
    http://www.springframework.org/schema/util 
    http://www.springframework.org/schema/util/spring-util-3.0.xsd
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

<tx:annotation-driven transaction-manager="txManager" />

<bean id="simpleJdbcTemplate"
    class="org.springframework.jdbc.core.JdbcTemplate">
    <constructor-arg ref="dataSource" />
</bean>

<bean id="transactionManager"
    class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource" />
</bean>

<!-- the DataSource (parameterized for configuration via a PropertyPlaceHolderConfigurer) -->
<bean id="dataSource"
    class="org.springframework.jdbc.datasource.SingleConnectionDataSource">
    <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>

</beans>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:p="http://www.springframework.org/schema/p"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
    http://www.springframework.org/schema/util 
    http://www.springframework.org/schema/util/spring-util-3.0.xsd">


  <util:properties id="appProperties" location="/WEB-INF/jdbc.properties" local-override="true"/>


<import resource="jdbc-config.xml" />

</beans>
但如果我使用

<bean id="propertyConfigurer"
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
    p:location="/WEB-INF/jdbc.properties" />

而不是

<util:properties ...

util:properties
不做属性解析,它只是创建一个
properties
bean。看


然而,
PropertyPlaceholderConfigurer
bean执行属性解析。它是一个
BeanFactoryPostProcessor
,它处理bean定义以解析任何属性占位符

util:properties
不做属性解析,它只是创建一个
properties
bean。看


然而,
PropertyPlaceholderConfigurer
bean执行属性解析。它是一个
BeanFactoryPostProcessor
,它处理bean定义以解析任何属性占位符

util:properties
不做属性解析,它只是创建一个
properties
bean。看


然而,
PropertyPlaceholderConfigurer
bean执行属性解析。它是一个
BeanFactoryPostProcessor
,它处理bean定义以解析任何属性占位符

util:properties
不做属性解析,它只是创建一个
properties
bean。看


然而,
PropertyPlaceholderConfigurer
bean执行属性解析。它是一个
BeanFactoryPostProcessor
,它处理bean定义以解析任何属性占位符

还有一个问题:如果我试图使用它,但它也不起作用。哦,我解决了这个问题。一切正常。关键是,我试图在上下文加载所有属性之前获取属性值。刚刚将属性占位符从servlet-context移到root-config.xml中。还有一个问题:如果我试图使用它,但它也不起作用。哦,我解决了这个问题。一切正常。关键是,我试图在上下文加载所有属性之前获取属性值。刚刚将属性占位符从servlet-context移到root-config.xml中。还有一个问题:如果我试图使用它,但它也不起作用。哦,我解决了这个问题。一切正常。关键是,我试图在上下文加载所有属性之前获取属性值。刚刚将属性占位符从servlet-context移到root-config.xml中。还有一个问题:如果我试图使用它,但它也不起作用。哦,我解决了这个问题。一切正常。关键是,我试图在上下文加载所有属性之前获取属性值。刚刚将属性占位符从servlet上下文移动到root-config.xml中。
<util:properties ...