The reference to entity "characterEncoding" must end with the ';'
在配置数据库连接池数据源时,本来没有错误,结果加上编码转换格式后eclipse突然报错:
这是怎么回事?
经过查询,发现这个错误其实很好解决。
首先,原因是: .xml文件中 ‘ & ’字符需要进行转义!!!
看到这里,其实已经恍然大悟,那么,这个字符 ‘ & ’ 需要怎么转义呢?看下面这张表:
在xml文件中有以下几类字符要进行转义替换:
所以,我们在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:aop="http://www.springframework.org/schema/aop"
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">
<!-- 管理DataSource -->
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<!-- set方法注入属性,和类中的成员属性无关,和set方法名称有关,比如有一个属性叫username,但是set方法:setName -->
<property name="driverClassName" value="com.mysql.cj.jdbc.Driver"></property>
<!-- 转义前 -->
<property name="url" value="jdbc:mysql://localhost:3306/demo?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai"></property>
<!-- 转义后 -->
<property name="url" value="jdbc:mysql://localhost:3306/demo?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai"></property>
<property name="username" value="root"></property>
<property name="password" value="root"></property>
</bean>
<!-- 管理jdbcTemplate -->
<bean id="template"
class="org.springframework.jdbc.core.JdbcTemplate">
<constructor-arg name="dataSource" ref="dataSource"></constructor-arg>
</bean>
</beans>
The reference to entity "characterEncoding" must end with the ';'的更多相关文章
- The reference to entity "characterEncoding" must end with the ';' delimiter
数据源配置时加上编码转换格式后出问题了: The reference to entity "characterEncoding" must end with the ';' del ...
- xml文件中配置JDBC源遇到问题 : The reference to entity "characterEncoding" must end with the ';' delimiter
数据源配置时加上编码转换格式后出问题了: The reference to entity"characterEncoding" must end with the ';' deli ...
- The reference to entity "characterEncoding" must end with the ';' delimiter (Mybatis + Mysql)
数据源配置时加上编码转换格式后出问题了: The reference to entity "characterEncoding" must end with the ';' del ...
- java报错:The reference to entity "characterEncoding" must end with the ';' delimiter.
java关于报错:The reference to entity "characterEncoding" must end with the ';' delimiter. Java ...
- 在java的xml文件配置数据库URL地址时提示The reference to entity "characterEncoding" must end with the ';' delimiter.错误信息
配置数据库的URL<property name="url" value="jdbc:mysql://127.0.0.1:3306/micro_message&quo ...
- XML报错:The reference to entity "characterEncoding" must end with the ';' delimite
解决方法: 在web.xml增加如下配置: <filter> <filter-name>encodingFilter</filter-name> <fil ...
- Caused by: org.xml.sax.SAXParseException: The reference to entity "characterEncoding" must end with the ';' delimiter.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Sourc ...
- 配置c3p0-config.xml数据库连接池,jdbcurl配置项报错Type The reference to entity "useUnicode" must end with the ';' delimiter.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE xml> <c3p0-confi ...
- 项目配置 xml文件时 报错提示(The reference to entity "useSSL" must end with the ';' delimiter.)
这次在配置xml文件时,出现错误提示( The reference to entity “useSSL” must end with the ‘;’ delimiter.) 报错行为 <prop ...
随机推荐
- docker相关概念介绍
关键词:docker容器与docker镜像 他们之间的关系是docker容器通过docker镜像来创建 docker镜像就是些像ubuntu15.10,ubuntu14.2一样的系统 docker容器 ...
- DDR3 DDR4 FPGA实现
基于7系列.virtex6等xilinx器件的MIG ip核设计DDR3/4读写控制器,以及基于arria 10器件的DDR4读写控制:DDR3/4的设计,设计的关键点是提高DDR3/4的访问效率,目 ...
- HashMap底层数据结构详解
一.HashMap底层数据结构 JDK1.7及之前:数组+链表 JDK1.8:数组+链表+红黑树 关于HashMap基本的大家都知道,但是为什么数组的长度必须是2的指数次幂,为什么HashMap的加载 ...
- Java工程师学习指南(完结篇)
Java工程师学习指南 完结篇 先声明一点,文章里面不会详细到每一步怎么操作,只会提供大致的思路和方向,给大家以启发,如果真的要一步一步指导操作的话,那至少需要一本书的厚度啦. 因为笔者还只是一名在校 ...
- Sql 六种约束
--1.主键约束问题 create table 学生表( 学号 int primary key, 姓名 varchar(10)); insert into 学生表 values(null,'a');问 ...
- Docker安装ELK并实现JSON格式日志分析
ELK是什么 ELK是elastic公司提供的一套完整的日志收集以及前端展示的解决方案,是三个产品的首字母缩写,分别是ElasticSearch.Logstash和Kibana. 其中Logstash ...
- 【Python秘籍】numpy到tensor的转换
在用pytorch训练神经网络时,我们常常需要在numpy的数组变量类型与pytorch中的tensor类型进行转换,今天给大家介绍一种它们之间互相转换的方法. 一.numpy到tensor 首先我们 ...
- opencv::两张图片的线性融合
理论-线性混合操作 g(x) 表示 融合图片中的像素点,f0(x) 和 f1(x) 分别表示背景和前景图片中的像素点. //参数1:输入图像Mat – src1 //参数2:输入图像src1的alph ...
- java-反编译工具(luyten)
下载地址:https://github.com/deathmarine/Luyten
- 基于 HTML5 + Canvas 实现楼宇自控系统
前言 楼宇自控是指楼宇中电力设备,如电梯.水泵.风机.空调等,其主要工作性质是强电驱动.通常这些设备是开放性的工作状态,也就是说没有形成一个闭环回路.只要接通电源,设备就在工作,至于工作状态.进程.能 ...