Prevent @Bean method from being called during @PreDestroy
This commit is contained in:
parent
6d4d495003
commit
faf02a21ab
|
|
@ -55,16 +55,20 @@ public class MongoRepositoriesAutoConfiguration {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private MongoProperties config;
|
private MongoProperties config;
|
||||||
|
private Mongo mongo;
|
||||||
|
|
||||||
@PreDestroy
|
@PreDestroy
|
||||||
public void close() throws UnknownHostException {
|
public void close() throws UnknownHostException {
|
||||||
mongo().close();
|
if (this.mongo != null) {
|
||||||
|
this.mongo.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean(Mongo.class)
|
@ConditionalOnMissingBean(Mongo.class)
|
||||||
Mongo mongo() throws UnknownHostException {
|
Mongo mongo() throws UnknownHostException {
|
||||||
return this.config.mongo();
|
this.mongo = this.config.mongo();
|
||||||
|
return this.mongo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue