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

错误提示:
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属性命名.

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

时间: 2024-11-06 22:39:28

java.lang.IllegalStateException: Failed to load ApplicationContext(2)的相关文章

java.lang.IllegalStateException: Failed to load ApplicationContext

1.错误描述 INFO:2015-02-05 22:14:21[main] - Loading XML bean definitions from class path resource [applicationContext.xml] INFO:2015-02-05 22:14:22[main] - JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning INFO:2015-02-05

junit测试时,出现java.lang.IllegalStateException: Failed to load ApplicationContext

课程设计要求进行junit测试,我是在已经做好的ssh项目上做的测试,测试类代码如下 package com.zhang.web.services; import static org.junit.Assert.*; import org.junit.After; import org.junit.Before; import org.junit.Test; import javax.annotation.Resource; import org.junit.runner.RunWith; im

java.lang.IllegalStateException: Failed to load property source from location &#39;classpath:/application.yml&#39;原因就是格式没有对齐导致的

导致报错原因就是格式问题,对齐就好了,百度竟然说编码导致的,郁闷 "C:\Program Files\Java\jdk1.8.0_101\bin\java" -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=63341 -Dcom.sun.management.jm

java.lang.IllegalStateException: Failed to check the status of the service

java.lang.IllegalStateException: Failed to check the status of the service com.pinyougou.sellergoods.service.BrandService. No provider available for the service com.pinyougou.sellergoods.service.BrandService from the url zookeeper://192.168.25.129:21

Caused by: java.lang.IllegalStateException: Failed to introspect Class [com.mchange.v2.c3p0.ComboPooledDataSource] from ClassLoader [ParallelWebappClassLoader

Caused by: java.lang.IllegalStateException: Failed to introspect Class [com.mchange.v2.c3p0.ComboPooledDataSource] from ClassLoader [ParallelWebappClassLoader 020-04-11 18:49:17,914 WARN [org.springframework.web.context.support.XmlWebApplicationConte

spring中junit 提示Failed to load ApplicationContext

错误提示: 1:java.lang.IllegalStateException: Failed to load ApplicationContext 2:Error creating bean with name 'userService' defined in class path resource [UserService.xml]: Initialization of bean failed; nested exception is org.springframework.aop.fram

常见Failed to load ApplicationContext异常解决方案!!

java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:125) at org.springframework.test.context.suppo

SpringBoot报错:Failed to load ApplicationContext(javax.websocket.server.ServerContainer not available)

引起条件: WebSocket+单元测试,单元测试报错! 解决方法: SpringBootTest增加webEnvironment参数. https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-testing.html#boot-features-testing-spring-boot-applications @SpringBootTest(webEnvironment = SpringBootT

Failed to load ApplicationContext

主要错误信息:java.lang.IllegalStateException: Failed to load ApplicationContext Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [h