我的本地机器上有一个 mysql 数据库,我正在尝试使用 mybatis 为这个新数据库上的 24 个表生成 POJO 类。我正在使用 MyBatis 网站上的示例:http: //mybatis.github.io/generator/running/runningWithJava.html
List<String> warnings = new ArrayList<String>();
boolean overwrite = true;
File configFile = new File("c:\\Users\\Ryan\\InfinityWorkspace\\Infinity\\src\\com\\ajtech\\infinity\\mybatis\\mybatisGenerator.xml");
ConfigurationParser cp = new ConfigurationParser(warnings);
Configuration config = cp.parseConfiguration(configFile);
DefaultShellCallback callback = new DefaultShellCallback(overwrite);
MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
myBatisGenerator.generate(null);
当我运行此代码时,控制台中不会发生异常,但运行此代码不会生成/生成任何内容。
我能够验证配置文件是否在我的 PC 上找到并且它正确解析它并且 mybatisGenerator.xml 文件中的 jdbc 连接我已使用我提供的用户名/密码成功地将我连接到 mysql 数据库。
任何想法为什么它不为我生成任何 XML / POJO 类?
我的 mybatisGenerator.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>
<context id="infinityDBTables">
<jdbcConnection connectionURL="jdbc:mysql://localhost:3307/infinitydb"
driverClass="com.mysql.jdbc.Driver"
userId="Ryan"
password="infinity">
</jdbcConnection>
<javaModelGenerator targetPackage="com.ajtech.infinity.database.dao.model" targetProject="\Infinity\src">
<property name="trimStrings" value="true" />
</javaModelGenerator>
<sqlMapGenerator targetPackage="com.ajtech.infinity.database.dao" targetProject="\Infinity\src"/>
<javaClientGenerator targetPackage="com.ajtech.infinity.database.dao.client" targetProject="\Infinity\src" type="XMLMAPPER"/>
<table tableName="AccessLevel" schema="infinitydb"/>
<table tableName="Brand" schema="infinitydb"/>
</context>
</generatorConfiguration>
现在,我承认,我确实注意到,无论我在表标签中提供什么表名或模式名,它仍然什么都不做,也没有给出错误....幕后的表名可能有错误吗?