1. 版本
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.1.0</version>
</dependency>
2. 配置
枚举配置指定 type-enums-package 枚举包名
mybatis-plus:
mapper-locations: "**/mapper/xml/**.xml"
configuration:
log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl
type-enums-package: net.mshome.twisted.tmall.enumeration
3. 枚举类写法
枚举类 enum 需实现mybatis-plus自带的IEnum<T>范型接口
import com.baomidou.mybatisplus.core.enums.IEnum;
public enum ProductStatus implements IEnum<Integer> {
/**
* 上架
*/
ON_SHELF(1),
/**
* 下架
*/
OFF_SHELF(0);
int value;
ProductStatus(int value) {
this.value = value;
}
@Override
public Integer getValue() {
return this.value;
}
}
4. 具体移步 https://github.com/baomidou/mybatis-plus-samples 中 mybatis-plus-sample-enum 项目