DeBug笔记

1.Spring

2.MyBatis

2.1MyBatis配置错误

2.1.1 UTF-8错误

Exception in thread “main”
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:
Line 36 in XML document from class path resource [spring-cfg4.xml] is
invalid; nested exception is org.xml.sax.SAXParseException;
lineNumber: 36; columnNumber: 11; 2 字节的 UTF-8 序列的字节 2 无效。
报错如上,原因是
在这里插入图片描述
将UTF-8写成UTF8
或者在pom.xml中进行一项配置
在这里插入图片描述
<properties> <!--这一行能够保证mybatis-config.xml不出错--> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties>

2.1.2 mybatis-config.xml找不到错误

Exception in thread “main” org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [spring-cfg4.xml]; nested exception is java.io.FileNotFoundException: class path resource [spring-cfg4.xml] cannot be opened because it does not exist
如果你的mybatis-config.xml没有放在resources文件夹下,那么在编译的时候,不会将xml和properties文件编译进去。
在这里插入图片描述
在pom.xml中进行配置
在这里插入图片描述
<build> <resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.properties</include> <include>**/*.xml</include> </includes> <filtering>true</filtering> </resource> </resources> </build>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值