码迷,mamicode.com
首页 > 移动开发 > 详细

java.lang.IllegalStateException: Failed to load ApplicationContext(2)

时间:2018-06-24 10:28:32      阅读:301      评论:0      收藏:0      [点我收藏+]

标签:cep   factor   mat   引入   type   eating   invalid   text   ret   

错误提示:
java.lang.IllegalStateException: Failed to load ApplicationContext

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘dataSource‘ defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property ‘jdbcUrl‘ of bean class [org.springframework.jdbc.datasource.DriverManagerDataSource]: Bean property ‘jdbcUrl‘ is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?

Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property ‘jdbcUrl‘ of bean class [org.springframework.jdbc.datasource.DriverManagerDataSource]: Bean property ‘jdbcUrl‘ is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?

Spring内置数据源配置:

<!-- 引入外部属性配置文件-->
<context:property-placeholder location="classpath:db.properties"/>

<!-- 配置内置的数据源bean,使用db.properties -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${jdbc.driverClass}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</bean>

c3p0连接池配置:

<!-- c3p0数据源,使用db.properties -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${jdbc.driverClass}"/>
<property name="jdbcUrl" value="${jdbc.url}"/>
<property name="user" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</bean>

错误原因:注意property中name属性命名.

java.lang.IllegalStateException: Failed to load ApplicationContext(2)

标签:cep   factor   mat   引入   type   eating   invalid   text   ret   

原文地址:https://www.cnblogs.com/zhengjinjun/p/9219298.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!