spring读取properties文件的问题
各位大吓,有空路过的时候帮忙看看呗。
系统启动日志:“INFO : org.springframework.beans.factory.config.PropertyPlaceholderConfigurer - Loading properties file from file [D:\Program Files\springsource\vfabric-tc-server-developer-2.5.0.RELEASE\appserver\wtpwebapps\WebServer\WEB-INF\classes\config.properties]”
-----------------------------------------------------------------------------------------------------------------------
config.properties内容:
default_encoding=UTF-8
locale=zh_CN
db.host=127.0.0.1
db.user=root
db.password=root
-----------------------------------------------------------------------------------------------------------------------
spring配置文件内容:
<context:property-placeholder location="classpath*:*.properties" />
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName">
<value>net.sourceforge.jtds.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:jtds:sqlserver://127.0.0.1;DatabaseName=DBTEST;autoReconnect=true
</value>
</property>
<property name="username" >
<value>${db.user}</value>
</property>
<property name="password">
<value>${db.password}</value>
</property>
</bean>
-----------------------------------------------------
上面是我的系统启动日志,明显已经把我的config.properties文件加载成功了,为什么我在spring配置文件中使用${db.user}就报错,报错信息:
严重: Servlet.service() for servlet [appServlet] in context with path [/WebServer] threw exception [Request processing failed; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: 用户 '${db.user}' 登录失败。] with root cause
java.sql.SQLException: 用户 '${db.user}' 登录失败。