在配置数据库连接池数据源时,本来没有错误,结果加上编码转换格式后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&amp;characterEncoding=UTF-8&amp;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 ';'的更多相关文章

  1. The reference to entity "characterEncoding" must end with the ';' delimiter

    数据源配置时加上编码转换格式后出问题了: The reference to entity "characterEncoding" must end with the ';' del ...

  2. xml文件中配置JDBC源遇到问题 : The reference to entity "characterEncoding" must end with the ';' delimiter

    数据源配置时加上编码转换格式后出问题了: The reference to entity"characterEncoding" must end with the ';' deli ...

  3. The reference to entity "characterEncoding" must end with the ';' delimiter (Mybatis + Mysql)

    数据源配置时加上编码转换格式后出问题了: The reference to entity "characterEncoding" must end with the ';' del ...

  4. java报错:The reference to entity "characterEncoding" must end with the ';' delimiter.

    java关于报错:The reference to entity "characterEncoding" must end with the ';' delimiter. Java ...

  5. 在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 ...

  6. XML报错:The reference to entity "characterEncoding" must end with the ';' delimite

    解决方法: 在web.xml增加如下配置: <filter>  <filter-name>encodingFilter</filter-name>  <fil ...

  7. 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 ...

  8. 配置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 ...

  9. 项目配置 xml文件时 报错提示(The reference to entity "useSSL" must end with the ';' delimiter.)

    这次在配置xml文件时,出现错误提示( The reference to entity “useSSL” must end with the ‘;’ delimiter.) 报错行为 <prop ...

随机推荐

  1. 安装sublime插件安装不上遇到的各种坑

    为了学习VUE , 发现没有高亮代码, 百度原来需要安装插件,安装过程中遇到了各种坑,记录下来避免大家踩坑, 首先用代码安装快捷键  ctrl+`   粘贴代码 import urllib.reque ...

  2. 【NOIP模拟赛】小奇的矩阵

    [题目背景] 小奇总是在数学课上思考奇怪的问题. [问题描述] 给定一个n*m的矩阵,矩阵中的每个元素aij为正整数. 接下来规定 1.合法的路径初始从矩阵左上角出发,每次只能向右或向下走,终点为右下 ...

  3. [转] Java 无界阻塞队列 DelayQueue 入门实战

    原文出处:http://cmsblogs.com/ 『chenssy』 DelayQueue是一个支持延时获取元素的无界阻塞队列.里面的元素全部都是"可延期"的元素,列头的元素是最 ...

  4. 各种常见文件的hex文件头

    我们在做ctf时,经常需要辨认各种文件头,跟大家分享一下一些常见的文件头.   扩展名 文件头标识(HEX) 文件描述 123 00 00 1A 00 05 10 04 Lotus 1-2-3 spr ...

  5. 刨ThreadLocal的坟

    ThreadLocal是大家比较常用到的,在多线程下存储线程相关数据十分合适.可是很多时候我们并没有深入去了解它的原理. 首选提出几个问题,稍后再针对这些问题一一解答. 提到ThreadLocal,大 ...

  6. 重载operator new delete函数

    可以重载global的operator new delete 函数,细节如下: MyNewDelete.h #pragma once #include <stdlib.h> #includ ...

  7. Docker 学习入门

    一.Docker 简介 1.什么是 Docker Docker 是使用最广泛的开源容器引擎,它彻底释放了计算虚拟化的威力,极大提高了应用的运行效率,降低了云计算资源供应的成本! 使用 Docker,可 ...

  8. top命令之性能分析

    top命令详解 当前时间20:27:12 当前系统运行时间3:18秒    1个用户   系统负载平均长度为0.00,0.00,0.00(分别为1分钟.5分钟.15分钟前到现在的平均值) 第二行为进程 ...

  9. HDU 1276 士兵队列训练问题(队列)

    题目网址:http://acm.hdu.edu.cn/showproblem.php?pid=1276 题目: 士兵队列训练问题 Time Limit: 2000/1000 MS (Java/Othe ...

  10. 微信分享—ios和安卓机制居然不一样!

     实际项目中,在做微信分享追踪的时候,遇到了一个百思不得其解的问题. 在加入了用户分享追踪功能之后,页面已经加载完成的情况下,安卓分享功能没有任何问题,ios却总是分享失败. 关于ios和安卓设备的差 ...