数据库连接org.springframework.beans.factory.unsatisfieddependencyexception

xe55xuns  于 2021-10-10  发布在  Java
关注(0)|答案(0)|浏览(234)

server.xml

<GlobalNamingResources>

  <Resource name="jdbc/ds" auth="Container" type="javax.sql.DataSource"
               maxTotal="100" maxIdle="30" maxWaitMillis="10000"
               username="test" password="test123" jdbcInterceptors="ConnectionState;StatementFinalizer" 
               url="jdbc:oracle:thin:@localhost:1521:SPRINGTEST/" validationQuery="select 1 from dual" />
</ GlobalNamingResources>

context.xml

<?xml version="1.0" encoding="UTF-8"?>
  <ResourceLink global="jdbc/ds" name="jdbc/ds" type="javax.sql.DataSource"/>
</Context>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app ....>
<resource-ref>
        <description>DB Connection</description>
        <res-ref-name>jdbc/ds</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>
</web-app>

dispatcher-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:p="http://www.springframework.org/schema/p" 
xmlns:context="http://www.springframework.org/schema/context" 
xmlns:mvc="http://www.springframework.org/schema/mvc" 
xmlns:aop="http://www.springframework.org/schema/aop" 
xmlns:jee="http://www.springframework.org/schema/jee" 
xmlns:lang="http://www.springframework.org/schema/lang" 
xmlns:tx="http://www.springframework.org/schema/tx" 
xmlns:util="http://www.springframework.org/schema/util" 
xmlns:beans="http://www.springframework.org/schema/beans" 
xmlns:security="http://www.springframework.org/schema/security" 
xmlns:task="http://www.springframework.org/schema/task" 
xmlns:cache="http://www.springframework.org/schema/cache" 
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd    
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd 
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd 
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/jee 
http://www.springframework.org/schema/jee/spring-jee.xsd 
http://www.springframework.org/schema/lang 
http://www.springframework.org/schema/lang/spring-lang.xsd
http://www.springframework.org/schema/tx 
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/util 
http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/security 
http://www.springframework.org/schema/security/spring-security.xsd
http://www.springframework.org/schema/task 
http://www.springframework.org/schema/task/spring-task.xsd
http://www.springframework.org/schema/cache 
http://www.springframework.org/schema/cache/spring-cache.xsd">

<mvc: annotation-driven /> 

<context: annotation-config /> 
<context:component-scan base-package="com.est.asg" />
<context:component-scan base-package="com.est.utils" />

<cache:annotation-driven key-generator="enhancedDefaultKeyGenerator" />
<beans:bean id="enhanced DefaultKeyGenerator" class="com.est.cache.interceptor.EnhancedDefaultKeyGenerator" />
<beans:bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager" p:cacheManager-ref="ehcache" />
<beans:bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" p:configLocation="classpath:ehcache.xml" p:shared="true" />

<beans:bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /> 
<property name="prefix" value="WEB-INF/pages/" />
<property name="suffix" value=".jsp" /> 
</beans:bean>

<resources mapping="/resources/***location="/resources/" />

<!-- DB --> 
<beans:bean id="estjdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"> 
<property name="dataSource" ref="dataSource" />
</beans:bean>

<beans:bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> 
<property name="jndiName">
<value>jdbc/ds</value>
</property>
</beans:bean>

<beans:bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager" scope="singleton"> 
<property name="dataSource" ref="dataSource" />
</beans:bean>

<tx:annotation-driven transaction-manager="transactionManager" />

<beans:bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> 
<property name="maxUploadSize" value="100000000" />
</beans:bean>

<task:executor id="Executor" pool-size="1" /> 
<task:scheduler id="Scheduler" pool-size="1" /> 
<task:annotation-driven executor="Executor" scheduler="Scheduler" />
</beans>

错误详细信息

SEVERE: Exception sending context initialized event to listener instance of class [org.springframework.web.context.ContextLoaderListener] org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authorizationInitializer': Unsatisfied dependency expressed through field 'SVCUtil'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'SVCUtil': Unsatisfied dependency expressed through field 'DAOUtil'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'DAOUtil': Unsatisfied dependency expressed through field 'estjdbcTemplate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with namenested exception is 'estjdbcTemplate' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name [jdbc/ds] is not bound in this Context. Unable to find [jdbc].

Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name [jdbc/ds] is not bound in this Context. Unable to find [jdbc].

Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name [jdbc/ds] is not bound in this Context. Unable to find [jdbc].

Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]:
Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name [jdbc/ds] is not bound in this Context. Unable to find [jdbc].

at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPost Processor.java:587)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(Injection Metadata.java:91)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcess PropertyValues(AutowiredAnnotationBeanPost Processor.java:373)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1344) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:582) 
at org.springframework.beans.factory.support.AbstractBeanFactory.lambdasdoGetBeans0(AbstractBeanFactory.java:312)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton (DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) 
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760) 
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:868)

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'SVCUtil': Unsatisfied dependency expressed through field 'DAOUtil'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'DAOUtil' Unsatisfied dependency expressed through field 'estjdbcTemplate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'estjdbcTemplate' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean the name 'dataSource' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name doc/ESTDB] is not bound in this Context. Unable to find [jdbc].

at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.injectautowiredAnnotationBeanPostProcessor.java:587)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91) 
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.stProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:373)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1344) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
at org.springfraork.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambdasdoGetBean50(AbstractBeanFactory.java:312)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310) 
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251)
at org.springframework.beans.factory.support.DefaultlistableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138) 
at org.springframwork.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1065) 
at org.springframework.beans.factory.annotation AutowiredAnnotationBeanPostProcessor$AutodredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:584)

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'DAOUtil' Unsatisfied dependency expressed through field 'estjdbcTemplate', nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'estjdbcTemplate' defined in ServletContext resource[/WEB-INF/dispatcher-servlet.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'datasource' nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name [jdbc/ds] is not bound in this Context. Unable to find [jdbc].

at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:587) 
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.pestProcessPropertyValues(AutowiredAnnotationBleanPostProcessor.java:373)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1344)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambdasdoGetBean50(AbstractBeanFactory.java:312)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) 
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310)
org.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251) 
at org.springframerk.beans.factory.support.DefaultListableBeanFactory.dofesolveDependency(DefaultListableBeanFactory.java:1138) 
at org.springframework.beans.factory.support.DefaultlistableBeanFactory.resolveDependency(DefaultiistableBeanFactory.java:1065)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:584)

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'estjdbcTemplate' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource' nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name [jdbc/ds] is not bound in this Context. Unable to find [jdbc]. 
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:378) 
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:110)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1613) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1357) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502) 
at org.springframework.beans.factory.support.AbstractBeanFactory.lambdasdoGetBean50(AbstractBeanFactory.java:312) 
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton (DefaultSingletonBeanRegistry.java:228) 
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) 
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251)
at org.springframework.beans.factory.support.DefaultlistableBeanFactory.doResolveDependency(DefaultlistableBeanFactory.java:1138) 
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultlistableBeanFactory.java:1065)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessorAutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:584)

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name [jdbc/ds] is not bound in this Context. Unable to find [jdbc]. 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1718)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:583) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:582)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312) 
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) 
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:367)

Caused by: javax.naming.NameNotFoundException: Name [jdbc/ds] is not bound in this context. Unable to find [jdbc].

at org.apache.naming.NamingContext.lookup(NamingContext.java:833)
at org.apache.naming.NamingContext.lookup(NamingContext.java:174)
at org.apache.naning.SelectorContext.lookup(SelectorContext.Java:163) 
at javax.naming.InitialContext.lookup(InitialContext.java:417)
at org.springframework.jndi.JndiTemplate.lambda$lookupse(jndiTemplate.java:156)
at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:91) 
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:156) 
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)
at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:96) 
at org.springframework.Jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:114) 
at org.springframework.Jndi.JndiObjectTargetSource.afterPropertiesSet(JndiObjectTargetSource.java:100)
at org.springframework.jndi.JndiObjectFactoryBean$JndiObjectProxyFactory.createJndiObjectProxy(JndiObjectFactoryBean.java:328) 
at org.springframework.jndi.JndiObjectFactoryBean$JndiObjectProxyFactory.access$000(JndiObjectFactoryBean.java:315)
at org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:207)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1769) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796) 

Related cause:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name [jdbc/ds] is not bound in this Context. Unable to find [jdbc].

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1710) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:583)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502)
at org.springframework.beans.factory.support.AbstractBeanFactory.LambdasdoGetBean$0(AbstractBeanFactory.java:312) 
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) 
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310) 
at org.springframework.beans.factory.support.AbstractBeanFactory.getTypeForFactoryBean(AbstractBeanFactory.java:1514)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryBean(AbstractAutowireCapableBeanFactory.java:845) 
at org.springframework.beans.factory.support.AbstractBeanFactory.isTypeMatch(AbstractBeanFactory.java:557) 
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:427)
at org.springframework.beans.factory.support.DefaultlistableBeanFactory.getBeanNamesForType(DefaultlistableBeanFactory.java:398) 
at org.springframework.beans.factory.BeanFactoryUtils.beanNamesForTypeIncludingAncestors(BeanFactoryUtils.java:222)
at org.springframework.beans.factory.support.DefaultlistableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1276)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultlistableBeanFactory.java:1101) 
at org.springframework.beans.factory.support.DefaultlistableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1065)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutodredAnnotationBeanPostProcessor.java:584) 
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91) 
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor-post ProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:373)
at org.springframework.beans.factory.support.AbstractAutowireCapablelleanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1344) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502) 
at org.springframework.beans.factory.support.AbstractBeanFactory.LambdasdoGetBean$0(AbstractBeanFactory.java:312) 
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251)
at org.springframework.beans.factory.support.DefaultlistableBeanFactory.doResolveDependency(DefaultiistableBeanFactory.java:1138) 
at org.springframework.beans.factory.support.DefaultlistableBeanFactory-resolveDependency(DefaultListableBeanFactory.java:1065) 
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:584) 
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(Injection Metadata.java:91) 
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPost Processor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:373) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1344)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambdasdoGetBean$0(AbstractBeanFactory.java:312)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) 
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310) 
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultlistableBeanFactory.java:760) 
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:868) 
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:409) 
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:291)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103) 
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4716) 
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5177)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) 
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) 
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)

Caused by: javax.naming.NameNotFoundException: Name [jdbc/ds] is not bound in this context. Unable to find [jdbc].
at org.apache.naming.NamingContext.lookup(NamingContext.java:833) 
at org.apache.naming.NamingContext.lookup(NamingContext.java:174)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:163) 
at javax.naming.InitialContext.lookup(InitialContext.java:417) 
at org.springframework.jndi.JndiTemplate.lambda$lookup$0(3ndiTemplate.java:156)
at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:91) 
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:156) 
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)
at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:96) 
at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:114) 
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:434) 
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.springframework.jndi.JndiObjectTargetSource.afterPropertiesSet(JndiObjectTargetSource.java:100)
at org.springframework.jndi.JndiobjectFactoryBean$JndiobjectProxyFactory.createJndiObjectProxy(JndiObjectFactoryBean.java:328) 
at org.springframework.jndi.JndiobjectFactoryBean$JndiObjectProxyFactory.access$000(JndiObjectFactoryBean.java:315) 
at org.springframework.jndi.JndiobjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:207)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1706) 

Related cause:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name [jdbc/ds] is not bound in this context. Unable to find [jdbc].
(AbstractAutowireCapableBeanFactory.java:1769) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean

我正在将SpringMVC版本从3.x升级到5.x。我正在尝试在tomcat server.xml文件中配置数据库连接设置。tomcat版本是9.x。编译时,我收到未满足的PendencyException错误消息。附加错误详细信息。请帮忙

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题