mybatisGenerator生成代码时,只有insert方法

本文介绍了MyBatis Generator的基本配置方法,特别是如何通过配置文件启用或禁用特定的数据库操作方法,例如根据主键查询、更新和删除记录等。同时,文章还提供了一个具体的例子,说明了当数据库表缺少主键时,可能会导致的问题及解决办法。

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

首先Generator中的文件配置是否有:

enableSelectByPrimaryKey="true" 

enableUpdateByPrimaryKey="false"
 enableDeleteByPrimaryKey="false"


<!--  绑定日志表  -->
        <table tableName="client_operate_platform_demo_tb" domainObjectName="PlatformDemoOperateLogInfo" 
               enableCountByExample="false" enableUpdateByExample="false"
               enableDeleteByExample="false" enableSelectByExample="false"
               enableSelectByPrimaryKey="true" enableUpdateByPrimaryKey="false"
               enableDeleteByPrimaryKey="false"  >
        </table>

配置之后仍然生成不了其他方法。查看数据库

发现在创建数据库忘记设置主键了

创建数据库语句

创建表
CREATE TABLE [dbo].[call_interface_log] (
[code] int  IDENTITY(1,1)   primary key,
[domain] varchar(100)  ,
[method] varchar(100)  ,
[params] varchar(1000)  ,
[account] varchar(50)  ,
[user_id] int,
[phone] varchar(20) ,
[start_time] datetime  ,
[end_time] datetime not NULL ,
[http_status_code] int  ,
[status] varchar(50) ,
[message] varchar(100)  ,
[result] varchar(MAX)  ,
[create_time] datetime ,
constraint PK_call_interface_log primary key (code)
)


go


删除表
drop table call_interface_log

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值