第一次使用Mybatis,由于公司核心服务器是AS400,参考了网络各个大大的教程后,发现无法使用Mybatis Generator自动生成AS400中的表对象
参考URL: http://www.cnblogs.com/smileberry/p/4145872.html
生成后会报如下错误
Table configuration with catalog null, schema null, and table ZKC03P did not resolve to any tables
最后通过增加schema解决
具体配置Config如下:
<?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="jt400-1.0.jar"/>
<context id="DB2Tables" targetRuntime="MyBatis3">
<commentGenerator>
<property name="suppressDate" value="true"/>
<property name="suppressAllComments" value="true"/>
</commentGenerator>
<!--数据库链接地址账号密码-->
<!--注:R21AFLBZ是我们库名称-->
<jdbcConnection driverClass="com.ibm.as400.access.AS400JDBCDriver" connectionURL="jdbc:as400://172.31.72.37/R21AFLBZ;errors=full;transaction isolation=none;date format=iso" userId="ABC123" password="ABC123">
</jdbcConnection>
<javaTypeResolver>
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<!--生成Model类存放位置-->
<javaModelGenerator targetPackage="pojo" targetProject="src">
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<!--生成映射文件存放位置-->
<sqlMapGenerator targetPackage="mapping" targetProject="src">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<!--生成Dao类存放位置-->
<javaClientGenerator type="XMLMAPPER" targetPackage="dao" targetProject="src">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<!--生成对应表及类名 注:重点修改在这里-->
<table schema="R21AFLBZ" tableName="ZKC03P" domainObjectName="ZKC03P" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
</context>
</generatorConfiguration>
执行命令
java -jar mybatis-generator-core-1.3.5.jar -configfile generatorConfig.xml -overwrite
其他配置参考网上设置即可