依赖版本
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.2.0</version>
</dependency>
实体配置,配置好@KeySequence和@TableId注解
yml配置
mybatis-plus:
mapper-locations: classpath*:mapper/oracle/**/*.xml
type-aliases-package: com.xxl.myoracle.keysequence.domain
global-config:
id-type: 1
# Sequence序列接口实现类配置
key-generator: com.baomidou.mybatisplus.extension.incrementer.OracleKeyGenerator
controller层
MybatisPlus save()请求报错:java.sql.SQLException: 无效的列类型: 1111
原因:未配置Sequence主键自增配置
解决方案: 添加MybatisPlusConfigurer配置文件,配置Sequence主键自增
@Configuration
@MapperScan("com.xxl.myoracle.keysequence.mapper")
public class MybatisPlusConfigurer {
/**
* Sequence主键自增
*
* @return 返回oracle自增类
* @author zhenggc
* @date 2019/1/2
*/
@Bean
public OracleKeyGenerator oracleKeyGenerator() {
return new OracleKeyGenerator();
}
}
配置好后,启动类添加@Configuration注解,发送请求即可成功