MybatisPlus 3.x 之后配置通过GlobalConfiguration全局主键策略遇到的一些问题:
运行环境:
Eclipse
框架背景:
1、Spring
2、MyBatisPlus
问题背景:
想要通过全局策略配置代替注解方式对JavaBean的主键进行自动增长。
在普通Bean类的主键名上,可以使用**@TableId(value=“”,type=AUTO)**,其中value是对应的列名;而type是主键策略,默认值是 ID_WORKER 。
我想通过全局策略配置的方式代替这种对每个Bean都亲自设置主键策略的方式,于是在applicationContext.xml中配置如下信息:
1、在 sqlSessionFactoryBean 下添加这个 globalConfig 这个属性。
<!-- 添加MP的全局配置策略 -->
<property name="globalConfig" ref="globalConfig"></property>
2、创建一个 GlobalConfig 的bean:
<!-- 定义MybatisPlus的全局策略配置 -->
<bean id="globalConfig" class="com.baomidou.mybatisplus.core.config.GlobalConfig">
<property nam