فهرست منبع

后期实现条件扫描 cn.reghao.bnt.web.admin 包, 根据是否扫描, 选择是否依赖 zookeeper

reghao 1 سال پیش
والد
کامیت
6e0dd4d7ef
2فایلهای تغییر یافته به همراه7 افزوده شده و 1 حذف شده
  1. 6 1
      web/src/main/java/cn/reghao/bnt/web/WebApplication.java
  2. 1 0
      web/src/main/resources/application-dev.yml

+ 6 - 1
web/src/main/java/cn/reghao/bnt/web/WebApplication.java

@@ -2,14 +2,19 @@ package cn.reghao.bnt.web;
 
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.boot.autoconfigure.domain.EntityScan;
 import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.FilterType;
 import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
 
 @SpringBootApplication
 @EnableJpaRepositories
 @EntityScan({"cn.reghao.bnt.web"})
-@ComponentScan({"cn.reghao.bnt.web", "cn.reghao.bnt.common"})
+@ComponentScan(basePackages = {"cn.reghao.bnt.web", "cn.reghao.bnt.common"}
+		,excludeFilters = @ComponentScan.Filter(type = FilterType.REGEX, pattern = {"cn.reghao.bnt.web.admin.*"})
+)
+//@ConditionalOnProperty()
 public class WebApplication {
 	public static void main(String[] args) {
 		SpringApplication.run(WebApplication.class, args);

+ 1 - 0
web/src/main/resources/application-dev.yml

@@ -1,6 +1,7 @@
 dubbo:
   registry:
     address: zookeeper://localhost:2181
+    #address: N/A
 spring:
   thymeleaf:
     cache: false