解决myBatis generator逆向生成没有根据主键的select,update和delete问题

网友投稿 391 2023-03-31

解决myBatis generator逆向生成没有根据主键的select,update和delete问题

解决myBatis generator逆向生成没有根据主键的select,update和delete问题

一、配置逆向generatoe.xml

PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"

"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">

connectionURL="jdbc:mysql://localhost:3306/ssm_crud?serverTimezone=UTC"

userId="root"

password="root">

connectionURL="jdbc:mysql://localhost:3306/ssm_crud?serverTimezone=UTC"

userId="root"

password="root">

http://

二、执行生成代码

public class MBGTest {

pubNqLikNlic static void main(String[] args) throws Exception{

List warnings = new ArrayList();

boolean overwrite = true;

File configFile = new File("mbg.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);

}

}

三、结果mapper中未能生成...ByPrimaryKey的方法

四、解决办法

在generatoe.xml的配置数据库连接信息时,添加

即可解决问题

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:电脑上怎么全屏打开小程序(电脑上怎么全屏打开小程序呢)
下一篇:简单了解redis常见客户端及Sharding机制原理
相关文章

 发表评论

暂时没有评论,来抢沙发吧~