Skip to content

Commit d28f4af

Browse files
committed
优化代码
1 parent e282b7c commit d28f4af

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/main/java/com/github/binarywang/demo/wx/mp/config/WxMpConfiguration.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
import java.util.List;
44
import java.util.Map;
55
import java.util.stream.Collectors;
6+
import javax.annotation.PostConstruct;
67

78
import org.springframework.beans.factory.annotation.Autowired;
89
import org.springframework.boot.context.properties.EnableConfigurationProperties;
9-
import org.springframework.context.annotation.Bean;
1010
import org.springframework.context.annotation.Configuration;
1111

1212
import com.github.binarywang.demo.wx.mp.handler.KfSessionHandler;
@@ -78,9 +78,9 @@ public static Map<String, WxMpService> getMpServices() {
7878
return mpServices;
7979
}
8080

81-
@Bean
82-
public Object services() {
83-
// 代码里getConfigs()处报错的同学,请注意仔细阅读项目说明,你的IDE需要引入lombok插件!!!!
81+
@PostConstruct
82+
public void initServices() {
83+
// 代码里 getConfigs()处报错的同学,请注意仔细阅读项目说明,你的IDE需要引入lombok插件!!!!
8484
final List<WxMpProperties.MpConfig> configs = this.properties.getConfigs();
8585
if (configs == null) {
8686
throw new RuntimeException("大哥,拜托先看下项目首页的说明(readme文件),添加下相关配置,注意别配错了!");
@@ -98,8 +98,6 @@ public Object services() {
9898
routers.put(a.getAppId(), this.newRouter(service));
9999
return service;
100100
}).collect(Collectors.toMap(s -> s.getWxMpConfigStorage().getAppId(), a -> a, (o, n) -> o));
101-
102-
return Boolean.TRUE;
103101
}
104102

105103
private WxMpMessageRouter newRouter(WxMpService wxMpService) {

0 commit comments

Comments
 (0)