我是靠谱客的博主 懦弱小伙,最近开发中收集的这篇文章主要介绍配置spring的时候出现的错误,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述


applicationContext.xml的配置:(重点看红色部分)

<bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource" destroy-method="close">
<property name="driver">
             <value>${datasource.connection.driver_class}</value>
         </property>
         <property name="driverUrl">
             <value>${datasource.connection.url}</value>
         </property>
         <property name="user">
             <value>${datasource.connection.username}</value>
         </property>
         <property name="password">
             <value>${datasource.connection.password}</value>
         </property>
         <property name="alias">
             <value>${datasource.connection.alias}</value>
         </property>
         <property name="prototypeCount">
             <value>${datasource.connection.prototypeCount}</value>
         </property>
         <property name="maximumConnectionCount">
             <value>${datasource.connection.maximumConnectionCount}</value>
         </property>
         <property name="minimumConnectionCount">
             <value>${datasource.connection.minimumConnectionCount}</value>
         </property>
         <property name="houseKeepingTestSql">
             <value>${datasource.connection.houseKeepingTestSql}</value>
          </property>
         <property name="testBeforeUse">
             <value>${datasource.connection.testBeforeUse}</value>
         </property>
         <property name="testAfterUse">
             <value>${datasource.connection.testAfterUse}</value>
         </property>
         <property name="trace">
             <value>${datasource.connection.trace}</value>
         </property>
    </bean>


数据库配置的文件:

datasource2.connection.url=jdbc:mysql://IP:3306/test?useUnicode=true&amp;characterEncoding=gbk

datasource2.connection.driver_class=com.mysql.jdbc.Driver

这样配置会出现如下错误:

严重: Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'dataSource' defined in ServletContext resource [/WEB-INF/config/applicationContext.xml]: Could not resolve placeholder 'jdbc.driver'
        at org.springframework.beans.factory.config.PropertyPlaceholderConfigure
r.processProperties(PropertyPlaceholderConfigurer.java:272)
        at org.springframework.beans.factory.config.PropertyResourceConfigurer.p
ostProcessBeanFactory(PropertyResourceConfigurer.java:75)
        at org.springframework.context.support.AbstractApplicationContext.invoke
BeanFactoryPostProcessors(AbstractApplicationContext.java:663)
        at org.springframework.context.support.AbstractApplicationContext.invoke
BeanFactoryPostProcessors(AbstractApplicationContext.java:638)
        at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:407)
        at org.springframework.web.context.ContextLoader.createWebApplicationCon
text(ContextLoader.java:276)
        at org.springframework.web.context.ContextLoader.initWebApplicationConte
xt(ContextLoader.java:197)
        at org.springframework.web.context.ContextLoaderListener.contextInitiali
zed(ContextLoaderListener.java:47)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContex
t.java:4323)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContex
t.java:4771)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:138)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.java:785)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:76
3)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:558)

        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.jav
a:1124)
        at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.j
ava:1047)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:542
)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1390)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java
:355)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
eSupport.java:119)
        at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBa
se.java:89)
        at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:31
2)
        at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:29
2)
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.ja
va:998)
        at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java
:772)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:138)
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.ja
va:990)
        at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.
java:275)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:138)
        at org.apache.catalina.core.StandardService.startInternal(StandardServic
e.java:424)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:138)
        at org.apache.catalina.core.StandardServer.startInternal(StandardServer.
java:648)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:138)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:576)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:415)
2010-7-27 11:18:35 org.apache.catalina.core.StandardContext startInternal

解决办法:将配置文件中的datasource2换成datasource就可以了

最后

以上就是懦弱小伙为你收集整理的配置spring的时候出现的错误的全部内容,希望文章能够帮你解决配置spring的时候出现的错误所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(66)

评论列表共有 0 条评论

立即
投稿
返回
顶部