(急急急100分)用过mybatis generator代码自动生成的朋友进来看看吧,感激不尽 mybatis generator 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 看看xml文件的<?xml version="1.0" encoding="UTF-8"?>之前是否有空格,回车之类的。 xml的格式存在问题,估计不规范 直接在别的地方拷的啊,能访问到xml里去,怎么改规范呢 直接在别的地方拷的啊,能访问到xml里去,怎么改规范呢 我也是用mybatis generator自动生成代码的,不过我用mybatis generator插件,在MyEclipse下自动生成。<?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> <context id="SQLSERVERTables" targetRuntime="MyBatis3" defaultModelType="conditional"> <plugin type="org.mybatis.generator.plugins.EqualsHashCodePlugin" /> <plugin type="org.mybatis.generator.plugins.MapperConfigPlugin"> <property name="fileName" value="GeneratedMapperConfig.xml" /> <property name="targetPackage" value="com.cy.mybatis.mbg.util" /> <property name="targetProject" value="Test" /> </plugin> <commentGenerator> <property name="suppressAllComments" value="true" /> </commentGenerator> <jdbcConnection driverClass="com.microsoft.jdbc.sqlserver.SQLServerDriver" connectionURL="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=Dsoktop" userId="sa" password=""> </jdbcConnection> <javaTypeResolver> <property name="forceBigDecimals" value="false" /> </javaTypeResolver> <!-- 生成 Model,POJO --> <javaModelGenerator targetPackage="com.xylcolor.vo.model" targetProject="项目名\src"> <property name="enableSubPackages" value="true" /> <property name="trimStrings" value="true" /> </javaModelGenerator> <!-- 生成映射文件*.xml --> <sqlMapGenerator targetPackage="mappers" targetProject="项目名\src"> <property name="enableSubPackages" value="true" /> </sqlMapGenerator> <!-- 生成映射器类 --> <javaClientGenerator type="XMLMAPPER" targetPackage="com.xylcolor.dao" targetProject="项目名\src"> <property name="enableSubPackages" value="true" /> </javaClientGenerator> <!-- 指定要生成的表名和对应形成的POJO类名 --> <table schema="" tableName="User" domainObjectName="User" /> </context></generatorConfiguration>不过没有分页,得自己写插件,有些麻烦 我的配置文件<?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="D:\generator\mysql-connector-java-5.1.5-bin.jar" /> <!-- <classPathEntry location="C:\oracle\product\10.2.0\db_1\jdbc\lib\ojdbc14.jar" />--> <context id="DB2Tables" targetRuntime="MyBatis3"> <commentGenerator> <property name="suppressAllComments" value="true" /> </commentGenerator> <!-- 数据库链接URL、用户名、密码 --> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/wcrm" userId="root" password="1234"> <!--<jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver" connectionURL="jdbc:oracle:thin:@localhost:1521:orcl" userId="msa" password="msa"> --> </jdbcConnection> <javaTypeResolver> <property name="forceBigDecimals" value="false" /> </javaTypeResolver> <!-- 生成模型的包名和位置 --> <javaModelGenerator targetPackage="sy.model" targetProject="D:\generator\src"> <property name="enableSubPackages" value="true" /> <property name="trimStrings" value="true" /> </javaModelGenerator> <!-- 生成的映射文件包名和位置 --> <sqlMapGenerator targetPackage="sy.mapping" targetProject="D:\generator\src"> <property name="enableSubPackages" value="true" /> </sqlMapGenerator> <!-- 生成DAO的包名和位置 --> <javaClientGenerator type="XMLMAPPER" targetPackage="sy.dao" targetProject="D:\generator\src"> <property name="enableSubPackages" value="true" /> </javaClientGenerator> <!-- 要生成那些表(更改tableName和domainObjectName就可以) --> <table tableName="student" domainObjectName="Student" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" /> </context></generatorConfiguration> 哎,真心不想用mybatis啊,太麻烦了,hibernate用的挺爽的 你这个<?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">是有问题,我放在MyEclipse中报错,你把我的那个上面拷过去再试试看 额,但是我用运行JAR文件可以啊,不然你用Myeclipse插件直接运行那个XML文件试试 将xml文件另存为ANSI格式竟可以了。 不要用记事本换成UTF-8格式的 会有个BOM头 JAVA读取的时候就会报错了 我认为17楼是正解,我也遇到这样的问题,我把该文件用notepad++打开,然后在菜单“格式”中选择“以UTF-8无BOM格式编码”,保存后就不会出错了。希望对大家有帮助。 今天刚好遇到这个错误,不是你的配置文件写错了,是你配置文件保存的格式错误了,你应该是直接用记事本打开编辑的,解决办法就是去找一个普通的xml文件,然后用notepad++ 或editpus等编辑工具打开,再把你的代码贴回去,保存即可将xml文件另存为ANSI格式竟可以了。不要用记事本换成UTF-8格式的 会有个BOM头 JAVA读取的时候就会报错了我把该文件用notepad++打开,然后在菜单“格式”中选择“以UTF-8无BOM格式编码”,上面的几种方式我没去试,我是直接拿一个平时的xml用非记事本的编辑工具打开,把代码贴上去就可以了,在强调一次,就是你文件的格式有问题 <!-- 注释里面必须加一个空格 --> 鉴定完毕 struts 参数问题,1到9能取到值,10个和10个以上的参数取不值 关于uuid的一系列问题 AJAX的轮询方式指的是什么? apache2.2 +Tomcat6.0 是如何实施部署在服务器? Jdeveloper问题 大家帮忙看下:一个简单的Struts 错在哪里? tomcat4.1 下配置数据源问题(水晶报表问题) Hibernate关联表查询的问题 请大家讨论一下,现在我们开发J2EE的Application Server还有没有机会,这里有没有这种人才? 探讨一个关于netty或者mina2的线程问题 如何提供weblogic JMS 的并发? 如何实现类似评论的效果?
<!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >
<generatorConfiguration>
<context id="SQLSERVERTables" targetRuntime="MyBatis3"
defaultModelType="conditional">
<plugin type="org.mybatis.generator.plugins.EqualsHashCodePlugin" />
<plugin type="org.mybatis.generator.plugins.MapperConfigPlugin">
<property name="fileName" value="GeneratedMapperConfig.xml" />
<property name="targetPackage" value="com.cy.mybatis.mbg.util" />
<property name="targetProject" value="Test" />
</plugin>
<commentGenerator>
<property name="suppressAllComments" value="true" />
</commentGenerator>
<jdbcConnection driverClass="com.microsoft.jdbc.sqlserver.SQLServerDriver"
connectionURL="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=Dsoktop"
userId="sa" password="">
</jdbcConnection> <javaTypeResolver>
<property name="forceBigDecimals" value="false" />
</javaTypeResolver> <!-- 生成 Model,POJO -->
<javaModelGenerator targetPackage="com.xylcolor.vo.model"
targetProject="项目名\src">
<property name="enableSubPackages" value="true" />
<property name="trimStrings" value="true" />
</javaModelGenerator> <!-- 生成映射文件*.xml -->
<sqlMapGenerator targetPackage="mappers"
targetProject="项目名\src">
<property name="enableSubPackages" value="true" />
</sqlMapGenerator> <!-- 生成映射器类 -->
<javaClientGenerator type="XMLMAPPER"
targetPackage="com.xylcolor.dao" targetProject="项目名\src">
<property name="enableSubPackages" value="true" />
</javaClientGenerator> <!-- 指定要生成的表名和对应形成的POJO类名 -->
<table schema="" tableName="User" domainObjectName="User" />
</context>
</generatorConfiguration>不过没有分页,得自己写插件,有些麻烦
<?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="D:\generator\mysql-connector-java-5.1.5-bin.jar" />
<!-- <classPathEntry location="C:\oracle\product\10.2.0\db_1\jdbc\lib\ojdbc14.jar" />-->
<context id="DB2Tables" targetRuntime="MyBatis3">
<commentGenerator>
<property name="suppressAllComments" value="true" />
</commentGenerator>
<!-- 数据库链接URL、用户名、密码 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/wcrm" userId="root" password="1234">
<!--<jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver" connectionURL="jdbc:oracle:thin:@localhost:1521:orcl" userId="msa" password="msa"> -->
</jdbcConnection>
<javaTypeResolver>
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<!-- 生成模型的包名和位置 -->
<javaModelGenerator targetPackage="sy.model" targetProject="D:\generator\src">
<property name="enableSubPackages" value="true" />
<property name="trimStrings" value="true" />
</javaModelGenerator>
<!-- 生成的映射文件包名和位置 -->
<sqlMapGenerator targetPackage="sy.mapping" targetProject="D:\generator\src">
<property name="enableSubPackages" value="true" />
</sqlMapGenerator>
<!-- 生成DAO的包名和位置 -->
<javaClientGenerator type="XMLMAPPER" targetPackage="sy.dao" targetProject="D:\generator\src">
<property name="enableSubPackages" value="true" />
</javaClientGenerator>
<!-- 要生成那些表(更改tableName和domainObjectName就可以) -->
<table tableName="student" domainObjectName="Student" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
</context>
</generatorConfiguration>
<!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN""http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">是有问题,我放在MyEclipse中报错,你把我的那个上面拷过去再试试看
不要用记事本换成UTF-8格式的 会有个BOM头 JAVA读取的时候就会报错了
我把该文件用notepad++打开,然后在菜单“格式”中选择“以UTF-8无BOM格式编码”,上面的几种方式我没去试,我是直接拿一个平时的xml用非记事本的编辑工具打开,把代码贴上去就可以了,在强调一次,就是你文件的格式有问题