mybatis-plus执行 SqlRunner.db().insert() 时 No value specified for parameter 1
时间: 2024-05-30 11:12:02 浏览: 9
这个问题通常是因为在执行 `SqlRunner.db().insert()` 时,插入的语句中没有给第一个参数赋值导致的。具体原因可能是插入语句中的参数数量不正确或者参数名称不正确。
你可以检查一下插入语句中的参数数量和名称是否正确,以及代码中是否正确传递了参数值。如果确定没有问题,可以考虑使用 Debug 模式来查找具体的问题所在,或者尝试使用 MyBatis-Plus 提供的其他插入方法,例如 `SqlRunner.db().insertBatch()` 或 `SqlRunner.db().insertObj()` 等。
相关问题
mybatis-plus.configuration.interceptors=
你好,`mybatis-plus.configuration.interceptors` 是 Mybatis-Plus 的配置属性,用于配置 Mybatis 的拦截器链。你可以在这个属性中添加多个拦截器,例如:
```
mybatis-plus.configuration.interceptors=com.example.MyInterceptor1,com.example.MyInterceptor2
```
这样就会按照顺序添加两个拦截器。
需要注意的是,在使用这个属性时,需要保证拦截器类可以被正确加载,通常需要在类路径下添加对应的 jar 包或者在项目中添加对应的依赖。同时,需要保证拦截器类实现了 Mybatis 的 Interceptor 接口。
另外,如果你使用的是 Spring Boot,也可以通过在配置文件中添加以下属性来配置 Mybatis 的拦截器链:
```
mybatis.configuration.interceptors=xxxInterceptor1,xxxInterceptor2
```
这样可以在 Spring Boot 中方便地配置 Mybatis 的拦截器链,而无需手动配置 Mybatis-Plus 的属性。
mybatis-plus.configuration.call-setters-on-nulls
mybatis-plus.configuration.call-setters-on-nulls 是MyBatis-Plus的一个配置项,用于控制是否在执行SQL时为null的值调用setter方法。默认情况下,MyBatis-Plus会为null值调用setter方法,以便在执行SQL时使用默认值或null值。如果将该配置项设置为false,则不会调用setter方法。
例如,假设有一个User实体类,其中有一个name属性和一个age属性。如果将call-setters-on-nulls设置为true,则当执行SQL时,如果name或age为null,则会自动调用对应的setter方法。如果将其设置为false,则不会调用setter方法,而是将null值传递给SQL语句。
这个配置项的具体使用方式可以参考MyBatis-Plus的官方文档。
相关推荐
![html](https://img-home.csdnimg.cn/images/20210720083451.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)