Closed connection [connectionId{XXXX}] to 172.16.11.47:27017 because the pool has been closed

快来打我* 2021-10-06 13:04 859阅读 0赞

启动直接报错,

环境为 springboot mongo

  1. . ____ _ __ _ _
  2. /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
  3. \\/ ___)| |_)| | | | | || (_| | ) ) ) )
  4. ' |____| .__|_| |_|_| |_\__, | / / / /
  5. =========|_|==============|___/=/_/_/_/
  6. :: Spring Boot :: (v2.0.3.RELEASE)
  7. 2019-10-29 20:25:15.078 INFO 26552 --- [ main] c.c.f.f.i.p.DefaultApplicationProvider : App ID is set to app-linglong-submit by app.id property from /META-INF/app.properties
  8. 2019-10-29 20:25:15.085 INFO 26552 --- [ main] c.c.f.f.i.p.DefaultServerProvider : Loading C:\opt\settings\server.properties
  9. 2019-10-29 20:25:15.085 INFO 26552 --- [ main] c.c.f.f.i.p.DefaultServerProvider : Environment is set to [DEV] by property 'env' in server.properties.
  10. 2019-10-29 20:25:16.800 INFO 26552 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
  11. 2019-10-29 20:25:16.844 INFO 26552 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
  12. 2019-10-29 20:25:17.843 INFO 26552 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
  13. 2019-10-29 20:25:17.844 INFO 26552 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.31
  14. 2019-10-29 20:25:17.849 INFO 26552 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [D:\soft\Java\jdk1.8.0_131\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS\;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Git\cmd;D:\soft\apache-maven-3.6.0\bin;D:\soft\mysql-5.7.25-winx64\bin;D:\soft\Java\jdk1.8.0_131\bin;C:\Program Files\nodejs\;C:\Program Files (x86)\Rational\common;C:\Program Files\Mozilla Firefox;D:\soft\xampp\php;C:\Program Files\erl10.4\bin;D:\soft\adb;D:\soft\Python\Python37\Scripts\;D:\soft\Python\Python37\;C:\Users\qubianzhong\AppData\Local\Microsoft\WindowsApps;C:\Users\qubianzhong\AppData\Roaming\npm;D:\soft\Microsoft VS Code\bin;C:\Users\qubianzhong\AppData\Local\BypassRuntm;C:\Program Files\JetBrains\WebStorm 2019.1.3\bin;;.]
  15. 2019-10-29 20:25:17.993 INFO 26552 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
  16. 2019-10-29 20:25:18.259 INFO 26552 --- [ main] c.a.d.s.b.a.DruidDataSourceAutoConfigure : Init DruidDataSource
  17. 2019-10-29 20:25:18.405 INFO 26552 --- [ main] com.alibaba.druid.pool.DruidDataSource : { dataSource-1} inited
  18. 2019-10-29 20:25:19.927 INFO 26552 --- [ main] org.mongodb.driver.cluster : Cluster created with settings { hosts=[172.16.11.47:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
  19. 2019-10-29 20:25:20.011 INFO 26552 --- [.16.11.47:27017] org.mongodb.driver.connection : Opened connection [connectionId{ localValue:1, serverValue:709}] to 172.16.11.47:27017
  20. 2019-10-29 20:25:20.020 INFO 26552 --- [.16.11.47:27017] org.mongodb.driver.cluster : Monitor thread successfully connected to server with description ServerDescription{ address=172.16.11.47:27017, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{ versionList=[3, 4, 19]}, minWireVersion=0, maxWireVersion=5, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=null, roundTripTimeNanos=8155700}
  21. 2019-10-29 20:25:20.322 INFO 26552 --- [ main] org.mongodb.driver.connection : Opened connection [connectionId{ localValue:2, serverValue:710}] to 172.16.11.47:27017
  22. 2019-10-29 20:25:20.772 INFO 26552 --- [ main] org.mongodb.driver.connection : Closed connection [connectionId{ localValue:2, serverValue:710}] to 172.16.11.47:27017 because the pool has been closed.
  23. 2019-10-29 20:25:20.775 INFO 26552 --- [ main] com.alibaba.druid.pool.DruidDataSource : { dataSource-1} closed
  24. 2019-10-29 20:25:20.775 INFO 26552 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
  25. Disconnected from the target VM, address: '127.0.0.1:61892', transport: 'socket'
  26. Process finished with exit code 1

我这个导致的原因是 项目里使用了RestTemplate, 但是在配置的过程中有改动,导致的问题

出现问题的RestTemplate配置代码

  1. package com.xxx.yyy.config;
  2. import org.springframework.context.annotation.Bean;
  3. import org.springframework.context.annotation.Configuration;
  4. import org.springframework.http.client.OkHttp3ClientHttpRequestFactory;
  5. import org.springframework.web.client.RestTemplate;
  6. @Configuration
  7. public class RestTemplateConfig {
  8. @Bean
  9. public RestTemplate restTemplate(OkHttp3ClientHttpRequestFactory factory){
  10. return new RestTemplate(factory);
  11. }
  12. @Bean
  13. public OkHttp3ClientHttpRequestFactory simpleClientHttpRequestFactory(){
  14. OkHttp3ClientHttpRequestFactory factory = new OkHttp3ClientHttpRequestFactory();
  15. factory.setConnectTimeout(60*1000);
  16. factory.setReadTimeout(60*1000);
  17. return factory;
  18. }
  19. }

修改为原来的,再次启动,正常启动

  1. package com.xxx.yyy.config;
  2. import org.springframework.context.annotation.Bean;
  3. import org.springframework.context.annotation.Configuration;
  4. import org.springframework.http.client.ClientHttpRequestFactory;
  5. import org.springframework.http.client.SimpleClientHttpRequestFactory;
  6. import org.springframework.web.client.RestTemplate;
  7. @Configuration
  8. public class RestTemplateConfig {
  9. @Bean
  10. public RestTemplate restTemplate(ClientHttpRequestFactory factory){
  11. return new RestTemplate(factory);
  12. }
  13. @Bean
  14. public ClientHttpRequestFactory simpleClientHttpRequestFactory(){
  15. SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
  16. factory.setConnectTimeout(60*1000);
  17. factory.setReadTimeout(60*1000);
  18. return factory;
  19. }
  20. }

发表评论

表情:
评论列表 (有 0 条评论,859人围观)

还没有评论,来说两句吧...

相关阅读