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 ...
随机推荐
- .net core session的使用步骤
步骤 操作 备注 1 Microsoft.AspNetCore.Session Microsoft.AspNetCore.Http.Extensions nuget安装包 2 ConfigureS ...
- mysql中间件分享(Mysql-prxoy,Atlas,DBProxy,Amoeba,cobar,TDDL)
hello 各位小伙伴大家好,我是小栈君,这期我们分享关于mysql中间件的研究,也就是数据层的读写分离和负载均衡,希望能够在实际的应用中能够帮助到各位小伙伴. 下期我们将继续分享go语言的系列讲解, ...
- flask 源码解析:上下文(一)
文章出处 https://www.cnblogs.com/jackchengcc/archive/2018/11/29/10025949.html 一:什么是上下文 每一段程序都有很多外部变量.只有 ...
- java零碎知识(每种数据类型默认值,多大,取值范围)
只要记下字节就好了 其它不必死记,取值范围:没有正负的,2的 字节数*8次方-1 , 凡是有正负的2的 (字节数*8)-1次方 -1 比如: 1.byte(有正负):先计算是2的几次方:字节数1*( ...
- PMBOK(第六版) PMP笔记——《十一》第十一章(项目风险管理)
PMBOK(第六版) PMP笔记——<十一>第十一章(项目风险管理) 第十一章 风险管理: 项目的独特性导致项目充满风险,项目风险是一种不确定的事件或条件,可能发生.将 要发生,也可能不发 ...
- 算法---ALGO-3 Java K好数 蓝桥杯
package Main; import java.io.InputStream; import java.util.Scanner; public class Main { public stati ...
- MFC::使用mysql
下载mysql-installer-community-5.7.16.0.msi,安装 mysql server即可. 创建工程包含头文件 #include "winsock.h" ...
- 告别硬编码,mysql 如何实现按某字段的不同取值进行统计
上周我突然意识到,我在grafana上写的 sql 语句存在多处硬编码.这篇笔记将记录如何实现没有硬编码的sql语句,以及自学编程过程中如何应对自己的笨拙代码和难题不断的状况. 1.有效但粗笨的硬编码 ...
- Python编程系列---使用字典实现路由静态路由
def index(): print('Index Page....') def bbs(): print('BBS Page....') def login(): print('Login Page ...
- 第一章、Python环境搭建
一.安装Python解释器 Windows下 Python开发环境搭建 1.官网下载: https://www.python.org/downloads/ 2.选择对应的版本 3.双击运行 4.选 ...