HikariCP使用Spring Cloud Config重新启动

时间:2019-01-16 19:14:28

标签: spring spring-boot spring-cloud hikaricp spring-cloud-config

我最近将我的应用程序配置为将Spring Cloud Config与Github一起用作配置存储库。

  
      
  • Spring Boot-2.1.1.Rosease
  •   
  • Spring Cloud依赖关系-Greenwich.RC2
  •   

我的应用程序几乎使用了所有现成的东西。我刚刚在IntentSender中配置了数据库,并且让HikariCP自动配置在后台发挥了作用。

我正在使用在RefreshEndpoint上调用createChooser方法的作业来刷新应用程序。

BroadcastReceiver

一切似乎都正常,但是每次刷新配置时都会看到以下日志。这些日志显示,每次刷新时,HikariCP池都会关闭并启动。

MyFragment

如果我查看这些日志的时间,大约需要8秒钟才能重新配置HikariCP。

由于应用程序上的负载现在还不多,所以到目前为止我的应用程序中还没有发现任何问题,但这是我要解决的几个问题。

  
      
  1. 重新启动HikariCP是否会导致应用程序负载增加的问题?

  2.   
  3. 如果重新启动会导致问题,是否可以不刷新HikariCP?

  4.   

2 个答案:

答案 0 :(得分:1)

HikariCP is made refreshable by default because a change made to it that seals the configuration once the pool is started.

So disable this, set spring.cloud.refresh.refreshables to an empty set.

答案 1 :(得分:0)

这对我有用(spring-boot- 2.2.7.RELEASE ,spring-cloud- Hoxton.SR4

spring.cloud.refresh.extra-refreshable=com.zaxxer.hikari.HikariDataSource