[英]Spring XML conf - join two params from jdbc.properties
I want to divide JDBC URL and URL params. 我想划分JDBC URL和URL参数。
In jdbc.properties I have: 在jdbc.properties中,我有:
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://db.server.tld:3306/dbName
jdbc.username=user
jdbc.password=pass
jdbc.urlParams=?useUnicode=true&characterEncoding=utf-8
In spring xml config: 在spring xml配置中:
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location"><value>classpath:jdbc.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}${jdbc.urlParams}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
But it doesn't work. 但这是行不通的。 Is there any way to join these two params?
有什么办法可以加入这两个参数?
Assuming that you have included Spring Expression Language (section 8.4) module with your application, you should be able to use the following: 假设您在应用程序中包括了Spring Expression Language (第8.4节)模块,则您应该能够使用以下内容:
#{'${jdbc.url}' + '${jdbc.urlParams}'}
as the value for url
property. 作为
url
属性的值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.