dos中mybatis generator自动生成出现xml parsers Error 前言中不允许有内容解决方法

在使用DOS运行java -jar generatoe-core生成mybatis代码时遇到XML Parsers Error,提示前言中不允许有内容。问题可能由XML文件编码或者错误引起。解决方法是使用Notepad++将XML文件以UTF-8无BOM格式编码保存,然后重新运行生成命令,即可成功自动生成代码。

xml文件:

<?xml version='1.0' encoding='UTF-8'?>

<!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<!-- 数据库驱动包位置 -->
<classPathEntry location="E:\MyLibs\MySQL\mysql-connector-java-5.1.30.jar" />
<context id="mysqltools" targetRuntime="MyBatis3">
<commentGenerator>
<property name="suppressAllComments" value="true" />
</commentGenerator>
<!-- 数据库链接URL、用户名、密码 -->
<jdbcConnection driverClass="org.gjt.mm.mysql.Driver" 
connectionURL="jdbc:mysql://127.0.0.1/petstore?Unicode=true&amp;characterEncoding=utf-8" 
userId="root" password="root">
</jdbcConnection>
<javaTypeResolver>
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<!-- 生成模型的包名和位置 -->
<javaModelGenerator targetPackage="com.vicky.model" 
targetProject="C:\mybatisgen">
<property name="enableSubPackages" value="true" />
<property name="trimStrings" value="true" />
</javaModelGenerator>
<!-- 生成的映射文件包名和位置 -->
<sqlMapGenerator targetPackage="com.vicky.mapping" 
targetProject="C:\mybatisgen">
<property name="enableSubPackages" value="true" />
</sqlMapGenerator>
<!-- 生成DAO的包名和位置 -->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.vicky.dao" 
targetProject="C:\mybatisgen">
<property name="enableSubPackages" value="true" />
</javaClientGenerator>
<!-- 要生成那些表(更改tableName和domainObjectName就可以)
更复杂的方式如下: 但基本不常用
<table tableName="tmenu" domainObjectName="Menu" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />

-->
<table tableName="account" domainObjectName="Account"  />
<table tableName="profile" domainObjectName="Profile"  />
<table tableName="category" domainObjectName="Category"  />
<table tableName="product" domainObjectName="Product"  />
<table tableName="item" domainObjectName="Item"  />
<table tableName="cart" domainObjectName="Cart"  />
<table tableName="orders" domainObjectName="Orders"  />

</context>

</generatorConfiguration>

dos:java -jar generatoe-core-1.3.2.jar -configfile generator.xml -overwrite 出现XML Parsers Error on line1 前言中不允许有内容

检查XML文件是否有错误,如果没有错误可能是编码问题

解决方案:用notepad++打开,选择“以UTF-8无BOM格式编码”格式,保存即可

在dos中输入  java -jar generatoe-core-1.3.2.jar -configfile generator.txt -overwrite,将会自动生成代码



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值