spring xml中的默认占位符值

Yev*_*ush 4 xml spring hibernate placeholder

在我们的特定应用程序中,db.properties文件由3d party提供.依赖于配置,此属性文件可以包含db.schema属性.因此,如果没有db.schema属性,则必须将db.username用于hibernate.default_schema属性.

如果db.schema不存在,则占位符$ {db.schema:db.username}不检索db.username的值,因此传播'db.schema'值而不是实际值(即dba).

所以,问题是:如果db.schema不存在,如何传播db.username的默认值(假设db.username始终存在)?

<util:properties id="specificHibernateProperties">
    <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
    <prop key="hibernate.show_sql">true</prop>
    <prop key="hibernate.hbm2ddl.auto">update</prop>
    <prop key="hibernate.default_schema">${db.schema:db.username}</prop>
</util:properties>
Run Code Online (Sandbox Code Playgroud)

小智 6

在Spring 3中,应该可以使用嵌套占位符.所以请试试这个:

${db.schema:${db.username}}
Run Code Online (Sandbox Code Playgroud)

/ rgrds