笔者在做MySQL逆向工程的时候碰到XML Parser Error on line 14: 对实体 “serverTimezone” 的引用必须以 ‘;’ 分隔符结尾,这个问题。
目录结构:
generatorConfig.xml部分代码
<jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/e3mall?useSSL=false&serverTimezone=UTC" userId="root"
password="root">
</jdbcConnection>
一开始我是懵逼的,尝试在serverTimezone=UTC后面加上一个“;”,修改成:
<jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/e3mall?useSSL=false&serverTimezone=UTC;" userId="root"
password="root">
</jdbcConnection>
然而,报错
在尝试多种方法之后,终于发现,原来是两个参数的连接字符出了问题,这个连接数据库的URL我是写在xml文件里面的,因此连接两个参数的字符”&“需要改为”&“。(如果使用properties配置文件来存放数据库连接字符串的话,参数之间连接可正常使用&)
<jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/e3mall?useSSL=false&serverTimezone=UTC" userId="root"
password="root">
</jdbcConnection>
成功运行