方法1:

application.yml

mybatis-plus:
  configuration:
    jdbc-type-for-null: 'null' #注意:单引号

方法2:

查看mp-starter-源码, MybatisPlusAutoConfiguration, 可以发现,第119行有一个configurationCustomizers,可以修改configuration

自定义一个,配上就完工

    @Bean
    public ConfigurationCustomizer configurationCustomizer(){
        return new MybatisPlusCustomizers();
    }

    class MybatisPlusCustomizers implements ConfigurationCustomizer {

        @Override
        public void customize(org.apache.ibatis.session.Configuration configuration) {
            configuration.setJdbcTypeForNull(JdbcType.NULL);
        }

方法3:

第一步:把 可更新为空的 javabean 属性前加上注解:@TableField(el = "username, jdbcType=VARCHAR")

@Email
@TableField(el = "email, jdbcType=VARCHAR")
private String email;

 第二步: 使用updateAllColumnById方法,而不是updateById.    如:
 this.baseMapper.updateAllColumnById(user); 
 

相关文章:

  • 2022-12-23
  • 2021-10-09
  • 2022-12-23
  • 2022-12-23
  • 2021-05-02
  • 2022-12-23
  • 2022-03-07
猜你喜欢
  • 2021-10-22
  • 2021-07-03
  • 2022-12-23
  • 2022-12-23
  • 2021-10-24
  • 2022-02-04
相关资源
相似解决方案