You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2022/03/21 07:22:50 UTC

[GitHub] [servicecomb-java-chassis] YOC19970520 commented on a change in pull request #2736: 【SCB-2422】change bean injection to constructor injection

YOC19970520 commented on a change in pull request #2736:
URL: https://github.com/apache/servicecomb-java-chassis/pull/2736#discussion_r830807369



##########
File path: governance/src/main/java/org/apache/servicecomb/governance/properties/GovernanceProperties.java
##########
@@ -53,12 +53,17 @@
 
   private final String configKey;
 
-  @Autowired
   protected Environment environment;
 
-  @Autowired
   private MicroserviceMeta microserviceMeta;
 
+  @Autowired
+  public GovernanceProperties(String configKey, Environment environment, MicroserviceMeta microserviceMeta) {
+    this.configKey = configKey;
+    this.environment = environment;
+    this.microserviceMeta = microserviceMeta;
+  }

Review comment:
        ```  
       protected GovernanceProperties(String key) {
       configKey = key;
       representer.getPropertyUtils().setSkipMissingProperties(true);
       GovernanceEventManager.register(this);
       entityClass = getEntityClass();
     }
   ```
   不删除,该构造方法里初始化了configKey; 将@Autowired改成setter方法注入,只注入environment和microserviceMeta




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org