Error creating bean with name 'dataSource' defined in ServletContext resource

struts-config.xml配置信息
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">







type="org.springframework.web.struts.DelegatingActionProxy">



<action path="/commonJump" parameter="method"
    type="org.springframework.web.struts.DelegatingActionProxy">
        <forward name="top" path="/WEB-INF/jsp/common/top.jsp" />
        <forward name="left" path="/WEB-INF/jsp/common/left.jsp" />
        <forward name="right" path="/WEB-INF/jsp/common/right.jsp" />   
</action>


<!-- 添加支持Spring的插件 -->



spring.xml配置信息

<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

<bean id="propertyConfigure"
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location" value="/WEB-INF/jdbc.properties" />
</bean>
<bean id="dataSource"
    class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="${database.driver}"></property>
    <property name="url" value="${database.url}"></property>
    <property name="username" value="${database.username}"></property>
    <property name="password" value="${database.password}"></property>
    <property name="initialSize" value="25" />
    <property name="maxActive" value="100" />
</bean>

<bean id="loginDao" class="com.af.family.dao.common.LoginDaoImpl">
    <property name="dataSource" ref="dataSource"></property>
</bean>

<!-- 对于Action组件配置,name,class。name的值是struts-config.xml中相应action的path值 -->
<bean name="/login" class="com.af.family.action.LoginAction">
    <property name="dao" ref="loginDao"></property>
</bean>

<bean name="/commonJump" class="com.af.family.action.CommonJumpAction">
</bean>

部署后出现如下错误:
[color=red]严重: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/spring.xml]: Initialization of bean failed; nested exception is org.springframework.beans.InvalidPropertyException: Invalid property 'initialSize' of bean class [org.springframework.jdbc.datasource.DriverManagerDataSource]: No property 'initialSize' found
Caused by: org.springframework.beans.InvalidPropertyException: Invalid property 'initialSize' of bean class [org.springframework.jdbc.datasource.DriverManagerDataSource]: No property 'initialSize' found
[/color]
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:376)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1107)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:857)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:423)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:291)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
at org.springframework.web.struts.ContextLoaderPlugIn.createWebApplicationContext(ContextLoaderPlugIn.java:354)
at org.springframework.web.struts.ContextLoaderPlugIn.initWebApplicationContext(ContextLoaderPlugIn.java:295)
at org.springframework.web.struts.ContextLoaderPlugIn.init(ContextLoaderPlugIn.java:225)
at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:869)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:336)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4045)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4351)
at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1105)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1203)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:293)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
at java.lang.Thread.run(Unknown Source)
2011-1-28 13:53:11 org.apache.catalina.core.ApplicationContext log

1个回答

org.springframework.beans.InvalidPropertyException: Invalid property 'initialSize' of bean class [org.springframework.jdbc.datasource.DriverManagerDataSource]: No property 'initialSize' found

根据提示应该是initialSize这个属性名写错了

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问