apolloconfig / apolloconfig/apollo

SpringCloud项目中注解方式使用客户端导致Spring启动失败

Aperta
#990 11 commenti 0 reazioni 0 assegnatari Vedi su GitHub
feature request
Lingua principale
Java
Stelle
29.8k
Fork
10.2k
Merge medio
4g 7h
PR unite (30g)
4

Descrizione

大神们好,我在SpringCloud(Spring core 4.2.6)中 使用Apollo Client,选用
[使用Spring Annotation支持](https://github.com/ctripcorp/apollo/wiki/Java%E5%AE%A2%E6%88%B7%E7%AB%AF%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97#323-spring-annotation%E6%94%AF%E6%8C%81)
这个方式启动失败,报错如下,还有一些Value注解的配置注入失败的信息没有贴出来。

```
[WARN] [17:26:00.336][DirectJDKLog][180]:The web application [ROOT] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:135)
com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:43)
[ERROR] [17:26:00.342][SpringApplication][827]:Application startup failed
```
如果我用
```
@Component //加上注解
public class TestApolloAnnotationBean {
@ApolloConfig
private Config config; //inject config for namespace application
@ApolloConfig("application")
private Config anotherConfig; //inject config for namespace application
@ApolloConfig("FX.apollo")
private Config yetAnotherConfig; //inject config for namespace FX.apollo

@Value("${batch:100}")
private int batch;
```
删除
```
@Configuration
@EnableApolloConfig
public class AppConfig {
@Bean
public TestApolloAnnotationBean testApolloAnnotationBean() {
return new TestApolloAnnotationBean();
}
}
```
并且application配置文件指定
```apollo.bootstrap.enabled: true```则可以启动成功。

问题:

1. 上文WIKI给出的注解配置是不是不支持SpringCloud?
2. apollo.bootstrap.enabled 是否必须是true,不然启动完后,private Config config 这个值为null?

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.