spring配置出错

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了spring配置出错相关的知识,希望对你有一定的参考价值。

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'personDao' defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'dataSource' is defined
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1308)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1067)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
at com.spring.dao.DaoRun.main(DaoRun.java:14)
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'dataSource' is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:509)
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1041)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:273)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
... 10 more

参考技术A 没有配置dataSource 参考技术B 错误很明显啊,说的也很清楚Error creating bean with name 'personDao' defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource';本回答被提问者和网友采纳 参考技术C 注入的问题

Spring配置文件出错

技术图片

问题描述

Element ‘xxxxxxx‘ cannot have character [children],because the type‘s content type is element-only

解决方案

配置文件中的beans节点下面只能是元素节点,不能有字符或文本存在。

比如多余的标点符号,点,也有可能是空格。

所以将9到12行注释成这样就行了;

<!--
//1.property表示给成员变量(属性)赋值
//2.调用set方法
//3.name表示属性名
//4.ref表示bean的id名
-->

以上是关于spring配置出错的主要内容,如果未能解决你的问题,请参考以下文章

mybatis整合spring获取配置文件信息出错

在 Spring Boot 应用程序中配置 Spring Vault 时出错

Spring配置文件出错

使用 spring boot 配置 SOAP 服务时出错

Spring配置相关问题出错 请帮忙指点一下 谢谢了!

Spring+ibatis通配符配置总是出错,求助,着急中。。