瀏覽代碼

新增 logo 属性控制是否打印 logo

hubin 7 年之前
父節點
當前提交
ccf09ecd6d

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

@@ -176,7 +176,7 @@ public class MybatisPlusAutoConfiguration {
     private void applyConfiguration(MybatisSqlSessionFactoryBean factory) {
     private void applyConfiguration(MybatisSqlSessionFactoryBean factory) {
         MybatisConfiguration configuration = this.properties.getConfiguration();
         MybatisConfiguration configuration = this.properties.getConfiguration();
         if (configuration == null && !StringUtils.hasText(this.properties.getConfigLocation())) {
         if (configuration == null && !StringUtils.hasText(this.properties.getConfigLocation())) {
-            configuration = new MybatisConfiguration();
+            configuration = new MybatisConfiguration().printLogo(this.properties.getGlobalConfig().isLogo());
         }
         }
         if (configuration != null && !CollectionUtils.isEmpty(this.configurationCustomizers)) {
         if (configuration != null && !CollectionUtils.isEmpty(this.configurationCustomizers)) {
             for (ConfigurationCustomizer customizer : this.configurationCustomizers) {
             for (ConfigurationCustomizer customizer : this.configurationCustomizers) {

+ 17 - 9
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/MybatisConfiguration.java

@@ -51,15 +51,23 @@ public class MybatisConfiguration extends Configuration {
      */
      */
     public MybatisConfiguration() {
     public MybatisConfiguration() {
         setDefaultScriptingLanguage(MybatisXMLLanguageDriver.class);
         setDefaultScriptingLanguage(MybatisXMLLanguageDriver.class);
-        System.out.println("___  ___       ______         _    _        ______  _             ");
-        System.out.println("|  \\/  |       | ___ \\       | |  (_)       | ___ \\| |            ");
-        System.out.println("| .  . | _   _ | |_/ /  __ _ | |_  _  ___   | |_/ /| | _   _  ___ ");
-        System.out.println("| |\\/| || | | || ___ \\ / _` || __|| |/ __|  |  __/ | || | | |/ __|");
-        System.out.println("| |  | || |_| || |_/ /| (_| || |_ | |\\__ \\  | |    | || |_| |\\__ \\");
-        System.out.println("\\_|  |_/ \\__, |\\____/  \\__,_| \\__||_||___/  \\_|    |_| \\__,_||___/");
-        System.out.println("          __/ |                                                   ");
-        System.out.println("         |___/                                              3.0.1");
-        System.out.println();
+    }
+
+    /**
+     * 打印 LOGO
+     */
+    public MybatisConfiguration printLogo(boolean print) {
+        if (print) {
+            System.out.println("___  ___       ______         _    _        ______  _             ");
+            System.out.println("|  \\/  |       | ___ \\       | |  (_)       | ___ \\| |            ");
+            System.out.println("| .  . | _   _ | |_/ /  __ _ | |_  _  ___   | |_/ /| | _   _  ___ ");
+            System.out.println("| |\\/| || | | || ___ \\ / _` || __|| |/ __|  |  __/ | || | | |/ __|");
+            System.out.println("| |  | || |_| || |_/ /| (_| || |_ | |\\__ \\  | |    | || |_| |\\__ \\");
+            System.out.println("\\_|  |_/ \\__, |\\____/  \\__,_| \\__||_||___/  \\_|    |_| \\__,_||___/");
+            System.out.println("          __/ |                                                   ");
+            System.out.println("         |___/                                              3.0.1\n");
+        }
+        return this;
     }
     }
 
 
     /**
     /**

+ 4 - 0
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/config/GlobalConfig.java

@@ -46,6 +46,10 @@ import lombok.experimental.Accessors;
 @SuppressWarnings("serial")
 @SuppressWarnings("serial")
 public class GlobalConfig implements Serializable {
 public class GlobalConfig implements Serializable {
 
 
+    /**
+     * 是否开启 LOGO
+     */
+    private boolean logo = true;
     /**
     /**
      * 是否刷新 mapper
      * 是否刷新 mapper
      */
      */

+ 1 - 1
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/spring/MybatisSqlSessionFactoryBean.java

@@ -430,7 +430,7 @@ public class MybatisSqlSessionFactoryBean implements FactoryBean<SqlSessionFacto
                 LOGGER.debug("Property 'configuration' or 'configLocation' not specified, using default MyBatis Configuration");
                 LOGGER.debug("Property 'configuration' or 'configLocation' not specified, using default MyBatis Configuration");
             }
             }
             // TODO 使用自定义配置
             // TODO 使用自定义配置
-            configuration = new MybatisConfiguration();
+            configuration = new MybatisConfiguration().printLogo(this.globalConfig.isLogo());
             if (this.configurationProperties != null) {
             if (this.configurationProperties != null) {
                 configuration.setVariables(this.configurationProperties);
                 configuration.setVariables(this.configurationProperties);
             }
             }