1.文档根元素 "beans" 必须匹配 DOCTYPE 根 "null"

这个原因是因为我自动扫描mapping.xml的文件路径设置错误,把它设置成spring-context的路径,然后报了这个莫名的错误。

2.自动注入时出现nullpointerexception,这个问题是因为没有很好理解spring的原理,参考链接如下:

https://stackoverflow.com/questions/19896870/why-is-my-spring-autowired-field-null

https://stackoverflow.com/questions/19869301/spring-autowired-object-nullpointerexception

也就是说,你不能简单的new一个对象来调用dao,你必须通过注入的方式,即在spring-context中创建bean id,然后才能用dao。

dao是接口,可以直接配置成自动扫描所有的dao,然后直接调用dao,无需实现dao。

3.spring Failed to convert property value of type 'java.lang.String' to required type 'int' for proper

用之前的方式就是不行,

换了个配置方式就可以了,真是奇怪了!参考链接:http://blog.csdn.net/tengdazhang770960436/article/details/45563969

换成如下形式就可以了:

<!-- 引入缓存的配置文件properties -->

<bean

class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">

<property name="ignoreResourceNotFound" value="true" />

<property name="ignoreUnresolvablePlaceholders" value="true" />

<property name="locations">

<list>

<!-- 此位置是相对于:部署后的项目根路径 -->

<!-- <value>/WEB-INF/cache.properties</value> -->

<!-- 此位置是相对于:文件直接在src 目录下 -->

<!-- <value>classpath*:cache.properties</value> -->

<!-- 此位置是相对于:文件在目录下面 -->

<!-- <value>classpath*:cache/cache.properties</value> -->

<value>classpath*:/cache/cache.properties</value>

<!-- 此位置是从服务器环境变量中查找名为:XXX 的值(例如:file:D:/test/test.properties) -->

<!-- <value>${XXX}</value> -->

<!-- 此位置是相对于:文件系统 -->

<!-- <value>file:D:/test/test.properties</value> -->

</list>

</property>

</bean>

4.expected at least 1 bean which qualifies as autowire candidate for this depende

自动扫描dao的时候,老是报这个错误,查了好多资料,发现,原来是我的目录配置错了!靠!!!浪费了一个下午!

所以配置spring的xml文件时一定要仔细。

spring配置遇到的问题的更多相关文章

  1. Spring配置c3p0数据源时出错报:java.lang.NoClassDefFoundError: com/mchange/v2/ser/Indirector

    今天在使用Spring配置c3p0数据源时,使用的数据库是mysql,服务器是tomcat,运行时报了一个 java.lang.NoClassDefFoundError: com/mchange/v2 ...

  2. Spring配置汇总

    现在主流的JavaWeb应用几乎都会用到Spring,以下是Spring的配置,以及结合Web的SpringMVC配置的汇总. jar包的引入 与Web项目集成 Spring配置文件 SpringMV ...

  3. spring配置属性的两种方式

    spring配置属性有两种方式,第一种方式通过context命名空间中的property-placeholder标签 <context:property-placeholder location ...

  4. 解决eclipse spring配置报错:cvc-elt.1: Cannot find the declaration of element

    解决eclipse spring配置报错:cvc-elt.1: Cannot find the declaration of element 'beans'.Referenced file conta ...

  5. spring配置详解

    1.前言 公司老项目的后台,均是基于spring框架搭建,其中还用到了log4j.jar等开源架包.在新项目中,则是spring和hibernate框架均有使用,利用了hibernate框架,来实现持 ...

  6. memcached 学习 1—— memcached+spring配置

    memcached 学习目录: memcached 学习 1—— memcached+spring配置 这几天自己搭建项目环境,解决问题如下: 有关常见的配置这里没有列出,中间遇到的搭建问题比较顺利g ...

  7. 解决spring配置中的bean类型的问题:BeanNotOfRequiredTypeException

    解决spring配置中的bean类型的问题:BeanNotOfRequiredTypeException这个问题出现的原因:一般在使用annotation的方式注入spring的bean 出现的,具体 ...

  8. spring配置中,properties文件以及xml文件配置问题

    spring方便我们的项目快速搭建,功能强大,自然也会是体系复杂! 这里说下配置文件properties管理的问题. 一些不涉及到代码逻辑,仅仅只是配置数据,可以放在xxxx.properties文件 ...

  9. IntelliJ IDEA通过Spring配置连接MySQL数据库

    先从菜单View→Tool Windows→Database打开数据库工具窗口,如下图所示: 点击Database工具窗口左上角添加按钮"+",选择Import from sour ...

  10. Dubbo中对Spring配置标签扩展

    Spring提供了可扩展Schema的支持,完成一个自定义配置一般需要以下步骤: 设计配置属性和JavaBean 编写XSD文件 编写NamespaceHandler和BeanDefinitionPa ...

随机推荐

  1. unity3d API知识点随记

    1.transform.translate是增加transform面板相应的数值x,y,z是以本地坐标系为方向:transform.transformdirection是以世界坐标系为方向,可以去测试 ...

  2. hdu1573-X问题-(扩展欧几里得定理+中国剩余定理)

    X问题 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...

  3. 安装beanstalkd

    运行下面命令安装: yum install epel-releaseyum -y install beanstalkd --enablerepo=epel

  4. 如何从Windows中删除Node.js

    如何从Windows中删除Node.js: 1.从卸载程序卸载程序和功能. 2.重新启动(或者您可能会从任务管理器中杀死所有与节点相关的进程). 3.寻找这些文件夹并删除它们(及其内容)(如果还有). ...

  5. JMeter学习(三十七)Jmeter录制手机app脚本(转载)

    转载自 http://www.cnblogs.com/yangxia-test 环境准备: 1.手机 2.wifi 3.Jmeter   具体步骤: 1.启动Jmeter: 2.“测试计划”中添加“线 ...

  6. Jmeter学习(三十二)调试工具Debug Sampler(转载)

    转载自 http://www.cnblogs.com/yangxia-test 一.Debug Sampler介绍: 使用Jmeter开发脚本时,难免需要调试,这时可以使用Jmeter的Debug S ...

  7. PHP 获取 IE浏览器版本号

    function getIEBrowserVersion(){ $agent = strtolower($_SERVER['HTTP_USER_AGENT']); if(strpos($agent, ...

  8. 弹出序列(python)

    题目描述 输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否可能为该栈的弹出顺序.假设压入栈的所有数字均不相等.例如序列1,2,3,4,5是某栈的压入顺序,序列4,5,3,2,1是该压 ...

  9. 2019年华南理工大学程序设计竞赛(春季赛)-C-六学家的困惑

    题目链接:https://ac.nowcoder.com/acm/contest/625/C 题意:给定两个字符串,每次只能从两个字符串的两端取字符,求依次取字符后所构成的数字最大为多少. 思路:思路 ...

  10. Ionic3错误: StaticInjectorError[HttpModule]: NullInjectorError: No provider for HttpModule!

    先在app.module.ts中导入HttpModule,才能在构造函数中注入Http. Ionic自动构建项目时,并没有导入HttpModule. 解决方案:打开app.module.ts,加入导入 ...