org.springframework.beans.factory.BeanDefinitionStoreException異常 ...
1、下麵是我遇到的異常信息:
2017-03-25 18:01:11,322 [localhost-startStop-1] [org.springframework.web.context.ContextLoader]-[ERROR] Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException:
Invalid bean definition with name 'dataSource' defined in file [C:\Users\Aaron\workspace\HT\target\classes\spring\applicationContext.xml]:
Could not resolve placeholder 'jdbc.driver' in string value "${jdbc.driver}";
nested exception is java.lang.IllegalArgumentException:
Could not resolve placeholder 'jdbc.driver' in string value "${jdbc.driver}"
2、異常信息中文翻譯:
Context initialization failed:
環境初始化失敗
BeanDefinitionStoreException:
這是一個異常對象:java bean 定義、註入異常
Invalid bean definition with name 'dataSource' defined in file:
無效的 java bean 定義,使用文件C:\Users\Aaron\workspace\HT\target\classes\spring\applicationContext.xml 為 dataSourece 類定義屬性時出錯:
Could not resolve placeholder 'jdbc.driver' in string value "${jdbc.driver}";
不能解析占位符 'jdbc.driver' in string value "${jdbc.driver}";
IllegalArgumentException
非法參數異常
3、查找錯誤
3.1 在 applicationContext.xml 里有如下配置:
<bean id="dataSource" class="com.zaxxer.hikari.HikariDataSource">
<property name="driverClassName" value="${jdbc.driver}"/>
3.2 在 db-mysql.properties 里有如下配置:
jdbc.driverClassName=com.mysql.jdbc.Driver
3.3 value的變數名為jdbc.driver,但在properties里配置的卻是jdbc.driverClassName
4、解決辦法
修改db-mysql.properties文件如下:
jdbc.driver=com.mysql.jdbc.Driver