WillemJiang commented on a change in pull request #772: [SCB-194] Spring 
default scan main class package
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/772#discussion_r196987741
 
 

 ##########
 File path: 
foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/BeanUtils.java
 ##########
 @@ -33,10 +42,41 @@ public static void init() {
     init(DEFAULT_BEAN_RESOURCE);
   }
 
+
   public static void init(String... configLocations) {
+    prepareServiceCombScanPackage();
+
     context = new ClassPathXmlApplicationContext(configLocations);
   }
 
+  public static void prepareServiceCombScanPackage() {
+    Set<String> scanPackags = new LinkedHashSet<>();
+    // add exists settings
+    String exists = System.getProperty(SCB_SCAN_PACKAGE);
+    if (exists != null) {
+      for (String exist : exists.trim().split(",")) {
+        if (!exist.isEmpty()) {
+          scanPackags.add(exist.trim());
+        }
+      }
+    }
+
+    // ensure servicecomb package exist
+    scanPackags.add(SCB_PACKAGE);
+
+    // add main class package
+    Class<?> mainClass = JvmUtils.findMainClass();
 
 Review comment:
   What if the main class is put into "a.b.c.main" and most the components are 
put into "a.b.c"?
   Can we define the scan path like the @SpringBootApplication basePackages 
provides in the Beans.init() method?
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to