Browse Source

修复inject-sql-session-on-mapper-scan无语法提示.

nieqiurong 1 year ago
parent
commit
3bcb816362

+ 4 - 2
mybatis-plus-boot-starter/src/main/java/com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.java

@@ -342,8 +342,10 @@ public class MybatisPlusAutoConfiguration implements InitializingBean {
             }
 
             // for spring-native
-            boolean injectSqlSession = environment.getProperty("mybatis.inject-sql-session-on-mapper-scan", Boolean.class,
-                Boolean.TRUE);
+            Boolean injectSqlSession = environment.getProperty("mybatis-plus.inject-sql-session-on-mapper-scan", Boolean.class);
+            if (injectSqlSession == null) {
+                injectSqlSession = environment.getProperty("mybatis.inject-sql-session-on-mapper-scan", Boolean.class, Boolean.TRUE);
+            }
             if (injectSqlSession && this.beanFactory instanceof ListableBeanFactory) {
                 ListableBeanFactory listableBeanFactory = (ListableBeanFactory) this.beanFactory;
                 Optional<String> sqlSessionTemplateBeanName = Optional

+ 6 - 0
mybatis-plus-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json

@@ -37,6 +37,12 @@
             "description": "A default scope for mapper bean that scanned by auto-configure.",
             "type": "java.lang.String"
         },
+        {
+            "defaultValue": true,
+            "name": "mybatis-plus.inject-sql-session-on-mapper-scan",
+            "description": "Set whether inject a SqlSessionTemplate or SqlSessionFactory bean (If you want to back to the behavior of 2.2.1 or before, specify false). If you use together with spring-native, should be set true.",
+            "type": "java.lang.Boolean"
+        },
         {
             "sourceType": "com.baomidou.mybatisplus.core.config.GlobalConfig",
             "name": "mybatis-plus.global-config.identifier-generator",