generator自动生成mybatis配置和类信息报Table configuration with catalog null错误

在使用generator自动生成MyBatis配置和类信息时遇到Table configuration错误,提示catalog null, schema或table未找到对应表。通过修改generator.xml配置文件,删除table元素中的schema属性解决了问题。对于Oracle和SqlServer数据库,需要移除该属性,而MySQL则无需此操作。" 128768549,13067879,Python字典items()方法详解,"['Python', '开发语言', '数据结构']

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

generator自动生成mybatis配置和类信息


本人用命令在测试的时候.. 出现下面的错误


C:\Users\xa>java -jar E:\mybatis-generator-core-1.3.1.jar -configfile D:\Workspaces\MyEclipse10\risenetba\src\generator.xml -overwrite
Table configuration with catalog null, schema orclba, and table zwdt_zidian did not resolve to any tables

MyBatis Generator finshed successfully, there were warninigs.


下面是generator.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:数据库的JDBC驱动的jar包地址 -->
	<classPathEntry
		location="D:\Workspaces\MyEclipse10\risenetba\defaultroot\WEB-INF\lib\ojdbc14.jar" />
	<context id="DB2Tables" targetRuntime="MyBatis3">
		<commentGenerator>
			<!-- 是否去除自动生成的注释 true:是 : false:否 -->
			<property name="suppressAllComments" value="true" />
			<!--数据库连接的信息:驱动类、连接地址、用户名、密码 -->
		</commentGenerator>
		<jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver"
			connectionURL="jdbc:oracle:thin:@xx.xx.x.xxx:1521:xx" userId="xx"
			password="1">
		</jdbcConnection>
		<!-- 默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer true,把JDBC DECIMAL 和 
			NUMERIC 类型解析为java.math.BigDecimal -->
		<javaTypeResolver>
			<property name="forceBigDecimals" value="false" />
		</javaTypeResolver>
		<!-- targetProject:自动生成代码的位置 -->
		<javaModelGenerator targetPackage="xgw.model"
			targetProject="D:\Workspaces\MyEclipse10\risenetba\src">
			<!-- enableSubPackages:是否让schema作为包的后缀 -->
			<property name="enableSubPackages" value="false" />
			<!-- 从数据库返回的值被清理前后的空格 -->
			<property name="trimStrings" value="true" />
		</javaModelGenerator>

		<sqlMapGenerator targetPackage="xgw.sqlmap"
			targetProject="D:\Workspaces\MyEclipse10\risenetba\src">
			<property name="enableSubPackages" value="false" />
		</sqlMapGenerator>

		<javaClientGenerator type="XMLMAPPER"
			targetPackage="xgw.mapping" targetProject="D:\Workspaces\MyEclipse10\risenetba\src">
			<property name="enableSubPackages" value="false" />
		</javaClientGenerator>
		<!-- tableName:用于自动生成代码的数据库表;domainObjectName:对应于数据库表的javaBean类名 -->
		<table schema="xx" tableName="zwdt_zidian" domainObjectName="zidian" 
			enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true" >
		</table>
	</context>

</generatorConfiguration>


后面发现去掉table中的schema属性就可以了..

经测试,如果数据库用的是Oracle,SqlServer需要去掉schema属性,MySQL则不需要去掉



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值