当前使用版本(必须填写清楚,否则不予处理)
springBootVersion = '2.1.3.RELEASE' springCloudVersion = 'Greenwich.RELEASE' mybatisPlusVersion = '3.1.0' ctripApolloVersion = '1.4.0' // 携程Apollo配置中心
该问题是怎么引起的?(最新版上已修复的会直接close掉)
重现步骤
mybaits-plus配置
mybatis-plus: mapper-locations: classpath:/mapper/*Mapper.xml global-config: banner: false db-config: id-type: 0 field-strategy: 1 table-underline: true logic-delete-value: 1 logic-not-delete-value: 0 configuration: map-underscore-to-camel-case: true
报错信息
APPLICATION FAILED TO START
Description:
Failed to bind properties under 'mybatis-plus.global-config.db-config.id-type' to com.baomidou.mybatisplus.annotation.IdType:
Property: mybatis-plus.global-config.db-config.id-type
Value: 0
Origin: "mybatis-plus.global-config.db-config.id-type" from property source "ApolloBootstrapPropertySources"
Reason: failed to convert java.lang.String to com.baomidou.mybatisplus.annotation.IdType
Action:
Update your application's configuration. The following values are valid:
AUTO
ID_WORKER
ID_WORKER_STR
INPUT
NONE
UUID
Comment From: miemieYaho
自己排查
Comment From: xavierzhao
@miemieYaho 有没有点建议?就这样关闭了?
Comment From: xavierzhao
最后debug发现异常
java.lang.IllegalArgumentException: No enum constant com.baomidou.mybatisplus.annotation.FieldStrategy.1
Comment From: xavierzhao
@miemieYaho 请问这里应该如何处理呢
Comment From: xavierzhao
Failed to bind properties under 'mybatis-plus.global-config.db-config.field-strategy' to com.baomidou.mybatisplus.annotation.FieldStrategy
Comment From: yuxiaobin
fieldStragety 的值:
IGNORED,
NOT_NULL,
NOT_EMPTY,
DEFAULT,
NEVER;``
Comment From: yuxiaobin
Comment From: xavierzhao
@yuxiaobin 非常感谢,问题解决了,很奇怪的是之前用的spring配置中心没问题,但是使用了携程的apollo配置中心后就出现问题了,mybatis-plus版本依然是3.1.0,没有发生变化。
spring配置中心配置
mybatis-plus:
mapper-locations: classpath:/mapper/*Mapper.xml
global-config:
banner: false
db-config:
id-type: 0
field-strategy: 1
table-underline: true
logic-delete-value: 1
logic-not-delete-value: 0
集成apollo之后配置
mybatis-plus:
mapper-locations: classpath:/mapper/*Mapper.xml
global-config:
banner: false
db-config:
id-type: auto
field-strategy: not_null
table-underline: true
logic-delete-value: 1
logic-not-delete-value: 0
另外一个问题,我这边IDEA没有弹出提示,只有黄色警告,需要怎么做才能有提示?
Comment From: yuxiaobin
可能是mp版本问题,请使用最新3.1.2试一下
Comment From: JanWarlen
给后来者提个醒,即便升级到最新3.5.3.1,集成apollo需要在apollo中配置mybatis-plus.global-config.db-config.id-type = auto,哪怕是spring的本地配置文件bootstrap.yml中也是不生效的