3

我正在尝试将 constretto (2.0.4) 与 Spring 3.2.3.RELEASE 一起使用。

我的 applicationContext.xml 文件:

<beans default-lazy-init="true"
xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:constretto="http://constretto.org/schema/constretto"

xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
    http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
    http://constretto.org/schema/constretto http://constretto.org/schema/constretto/constretto-1.2.xsd
">

<constretto:configuration annotation-config="true" property-placeholder="true">
    <constretto:stores>
        <constretto:properties-store>
            <constretto:resource location="file:/data/config/app.properties"/>
        </constretto:properties-store>
    </constretto:stores>
</constretto:configuration>

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
        destroy-method="close"
        lazy-init="false"
        p:driverClassName="${jdbc.driver}"
        p:url="${jdbc.url}"
        p:username="${jdbc.user}"
        p:password="${jdbc.password}"
        p:initialSize="5"
        p:maxActive="100"
        p:maxIdle="30"
        p:maxWait="1000"
        p:poolPreparedStatements="true"
        p:defaultAutoCommit="false"
        p:removeAbandoned="true"
        p:removeAbandonedTimeout="60">
</bean>

我有一个包含所有属性的 app.properties 文件,看起来它根本没有加载,没有调用任何 constretto 类。

我得到错误:

Could not resolve placeholder 'jdbc.driver' in string value "${jdbc.driver}"

知道为什么它不起作用吗?有人在这种整合上取得成功吗?

4

1 回答 1

0

它适用于 Constretto 2.2 版

于 2015-03-27T17:11:34.390 回答