确认
- [x] 我使用的版本是最新版, 并且使用插件确认过项目里无依赖版本冲突
- [x] 我已经在 issue 中搜索过, 确认问题没有被提出过
- [x] 我已经修改标题, 将标题中的 描述 替换为遇到的问题(不得删除 描述 前面的部分)
当前程序版本
3.5.14
问题描述
环境
- SpringBoot: 4.0.0-M3
- mybatis-plus-spring-boot4-starter: 3.5.14
启动失败原因
Springboot4.0.0-M3
的PropertyMapper
没有apialwaysApplyingWhenNonNull
错误代码
mybatis-plus-spring-autoaonfigure
.com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties
public class MybatisPlusProperties{
// ...
public void applyTo(MybatisConfiguration target) {
PropertyMapper mapper = PropertyMapper.get().alwaysApplyingWhenNonNull();
// ...
}
// ...
}
分析
看起来 已经不需要 alwaysApplyingWhenNonNull
, 因为 to
已经判断 value != null了
public class PropertyMapper {
/**
* Complete the mapping by passing any non-filtered value to the specified
* consumer. The method is designed to be used with mutable objects.
* @param consumer the consumer that should accept the value if it's not been
* filtered
*/
public void to(Consumer<? super T> consumer) {
Assert.notNull(consumer, "'consumer' must not be null");
T value = getValue();
if (value != null && test(value)) {
consumer.accept(value);
}
}
}
如果要兼容的话可以这样,如果觉得可以的话我可以提交一个PR
PropertyMapper mapper = PropertyMapper.get().alwaysApplying(new PropertyMapper.SourceOperator() {
@Override
public <T> PropertyMapper.Source<T> apply(PropertyMapper.Source<T> source) {
return source.when(Objects::nonNull);
}
});
Comment From: nieqiurong
用3.5.15-SNAPSHOT试试,快照使用参考: https://baomidou.com/getting-started/install
Comment From: coder-xiaomo
遇到相同问题,本地使用 3.5.15-SNAPSHOT 版本可以解决👍
Comment From: moil-xm
用3.5.15-SNAPSHOT试试,快照使用参考: https://baomidou.com/getting-started/install
成功解决。