Browse Source

增加了关闭系统初始化的功能,可以通过设置hsweb.app.auto-init=false来关闭启动时自动初始化.

zhouhao 6 years ago
parent
commit
7bc521f182

+ 6 - 32
hsweb-starter/hsweb-spring-boot-starter/src/main/java/org/hswebframework/web/starter/AppProperties.java

@@ -18,13 +18,19 @@
 
 package org.hswebframework.web.starter;
 
+import lombok.Getter;
+import lombok.Setter;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 
 /**
  * @author zhouhao
  */
 @ConfigurationProperties(prefix = "hsweb.app")
+@Getter
+@Setter
 public class AppProperties {
+    private boolean autoInit = true;
+
     private String name;
     private String comment;
     private String website;
@@ -38,36 +44,4 @@ public class AppProperties {
         systemVersion.setVersion(version);
         return systemVersion;
     }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public String getComment() {
-        return comment;
-    }
-
-    public void setComment(String comment) {
-        this.comment = comment;
-    }
-
-    public String getWebsite() {
-        return website;
-    }
-
-    public void setWebsite(String website) {
-        this.website = website;
-    }
-
-    public String getVersion() {
-        return version;
-    }
-
-    public void setVersion(String version) {
-        this.version = version;
-    }
 }

+ 8 - 1
hsweb-starter/hsweb-spring-boot-starter/src/main/java/org/hswebframework/web/starter/SystemInitializeAutoConfiguration.java

@@ -18,6 +18,7 @@
 
 package org.hswebframework.web.starter;
 
+import lombok.extern.slf4j.Slf4j;
 import org.hswebframework.ezorm.rdb.executor.SqlExecutor;
 import org.hswebframework.ezorm.rdb.meta.RDBDatabaseMetaData;
 import org.hswebframework.ezorm.rdb.meta.parser.H2TableMetaParser;
@@ -63,6 +64,7 @@ import java.util.stream.Stream;
 @Configuration
 @EnableConfigurationProperties(AppProperties.class)
 @Order(Ordered.HIGHEST_PRECEDENCE)
+@Slf4j
 public class SystemInitializeAutoConfiguration implements CommandLineRunner, BeanPostProcessor {
 
     @Autowired
@@ -107,9 +109,14 @@ public class SystemInitializeAutoConfiguration implements CommandLineRunner, Bea
 
     @Override
     public void run(String... args) throws Exception {
+
+        if (!appProperties.isAutoInit()) {
+            log.debug("app auto init is disabled");
+            return;
+        }
         DatabaseType type = DataSourceHolder.currentDatabaseType();
         SystemVersion version = appProperties.build();
-        if(version.getName()==null){
+        if (version.getName() == null) {
             version.setName("unknown");
         }
         Connection connection = null;