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

来源:互联网 发布:mac突然无法连接wifi 编辑:程序博客网 时间:2024/05/21 09:02

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,将会自动生成代码



0 0