[
https://issues.apache.org/jira/browse/SCB-194?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16518785#comment-16518785
]
ASF GitHub Bot commented on SCB-194:
------------------------------------
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:
[email protected]
> Improve component-scan setting
> ------------------------------
>
> Key: SCB-194
> URL: https://issues.apache.org/jira/browse/SCB-194
> Project: Apache ServiceComb
> Issue Type: Improvement
> Components: Java-Chassis
> Reporter: yangyongzheng
> Assignee: wujimin
> Priority: Major
> Labels: roadmap
>
> Current in Producer side,we need add META-INF/spring/xxx.bean.xml file
> contains:
> <context:component-scan base-package="xxx.xxx.xxx" />
> in order to define base package path,we may need find a way to add main class
> package to component-scan path automatically
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)