spring 4.3.1中使用外部属性文件使c3p0链接数据库时遇到的一个bug
时间: 2016-07-15来源:开源中国
前景提要
HDC调试需求开发(15万预算),能者速来!>>> Spring中 通过 在applicationContext.xml文件中 引入db.properties.xml外部属性文件来链接数据库 < context :property-placeholder location ="classpath:db.properties" />
db.properties.xml文件内容如下: user = root password = 123456 driverClass = com.mysql.cj.jdbc.Driver jdbcUrl = jdbc:mysql://shop?autoReconnect=true&useSSL=false
配置bean时,用"${user}", "${password}" ,"${driverClass}"来获取属性值,
但是在运行时,发现c3p0不能链接数据库,debug发现在获取user属性值时出错,而其他的属性值是正确的
< property name ="user" value ="${user}" /> 只有这里获取的值是错误的 < property name ="password" value ="${password}" /> < property name ="driverClass" value ="${driverClass}" /> < property name ="jdbcUrl" value ="${jdbcUrl}" />


如果不使用外部属性文件配置,直接写成
< property name ="user" value ="root" /> 时,c3p0是可以链接到mysql上的
有人遇到过同样的问题吗?

科技资讯:

科技学院:

科技百科:

科技书籍:

网站大全:

软件大全:

热门排行