使用 Spring Boot 代码运行 docker 容器

Posted

技术标签:

【中文标题】使用 Spring Boot 代码运行 docker 容器【英文标题】:running docker container with spring boot code 【发布时间】:2018-11-28 14:31:16 【问题描述】:
Am getting below error when am running my spring boot application in docker container.Any idea why am facing this issue.

以下是出现的错误。

无需在 docker 容器中部署即可运行应用程序。

docker run -p 2000:2000 docker-aws-test

trationDelegate$BeanPostProcessorChecker : [class org.springframework.cloud.aws.core.config.AmazonWebserviceClientFactoryBean] 类型的 Bean 'amazonRDS' 不符合所有 BeanPostProcessor 的处理条件(例如:不符合自动代理的条件) 2018-06-19 14:53:29.152 INFO 1 --- [main] trationDelegate$BeanPostProcessorChecker:[class com.amazonaws.services.rds.AmazonRDSClient] 类型的 Bean 'amazonRDS' 不符合所有 BeanPostProcessor 处理的条件(例如:不符合自动代理的条件) 2018-06-19 14:53:29.307 信息 1 --- [main] trationDelegate$BeanPostProcessorChecker:Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' 类型 [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB $$41ba31b0] 不符合被所有 BeanPostProcessor 处理的条件(例如:不符合自动代理的条件) 2018-06-19 14:53:29.832 INFO 1 --- [main] s.b.c.e.t.TomcatEmbeddedServletContainer:Tomcat 使用端口初始化:2000 (http) org.springframework.beans.factory.BeanCreationException:无法自动装配字段:私有 javax.sql.DataSource org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.dataSource;嵌套异常是 org.springframework.beans.factory.BeanCreationException:创建名为“$db-instance-identifier”的 bean 时出错:调用 init 方法失败;嵌套异常是 com.amazonaws.SdkClientException: Unable to execute HTTP request: Unsupported record version Unknown-0.0 在 org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] 在 org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:368) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] 在 org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] 在 org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1054) ~[spring-context-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] 在 org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:829) ~[spring-context-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] 在 org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) ~[spring-context-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] 在 org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.3.RELEASE.jar!/:1.3.3.RELEASE] 在 org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766) [spring-boot-1.3.3.RELEASE.jar!/:1.3.3.RELEASE] 在 org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361) [spring-boot-1.3.3.RELEASE.jar!/:1.3.3.RELEASE] 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-1.3.3.RELEASE.jar!/:1.3.3.RELEASE] 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:1191) [spring-boot-1.3.3.RELEASE.jar!/:1.3.3.RELEASE] 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:1180) [spring-boot-1.3.3.RELEASE.jar!/:1.3.3.RELEASE] 在 com.miss.equipoptimization.Application.main(Application.java:11) [rulecreation-0.1.0.jar!/:0.1.0] 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131] 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131] 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131] 在 java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131] 在 org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:54) [rulecreation-0.1.0.jar!/:0.1.0] 在 java.lang.Thread.run(Thread.java:748) [na:1.8.0_131] 引起:org.springframework.beans.factory.BeanCreationException:无法自动装配字段:私有 javax.sql.DataSource org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.dataSource;嵌套异常是 org.springframework.beans.factory.BeanCreationException:创建名为“$db-instance-identifier”的 bean 时出错:调用 init 方法失败;嵌套异常是 com.amazonaws.SdkClientException: Unable to execute HTTP request: Unsupported record version Unknown-0.0 在 org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] 在 org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] 在 org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] ...省略了32个常用框架 原因:org.springframework.beans.factory.BeanCreationException:创建名为'$ db-instance-identifier'的bean时出错:调用init方法失败;嵌套异常是 com.amazonaws.SdkClientException: Unable to execute HTTP request: Unsupported record version Unknown-0.0 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] 在 org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] 在 org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] 在 org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] 在 org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] 在 org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] ...省略了34个常用框架 引起:com.amazonaws.SdkClientException:无法执行 HTTP 请求:不支持的记录版本 Unknown-0.0 在 com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleRetryableException(AmazonHttpClient.java:1116) ~[aws-java-sdk-core-1.11.319.jar!/:na] 在 com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1066) ~[aws-java-sdk-core-1.11.319.jar!/:na] 在 com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:743) ~[aws-java-sdk-core-1.11.319.jar!/:na] 在 com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:717) ~[aws-java-sdk-core-1.11.319.jar!/:na] 在 com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:699) ~[aws-java-sdk-core-1.11.319.jar!/:na] 在 com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:667) ~[aws-java-sdk-core-1.11.319.jar!/:na] 在 com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:649) ~[aws-java-sdk-core-1.11.319.jar!/:na] 在 com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:513) ~[aws-java-sdk-core-1.11.319.jar!/:na] 在 com.amazonaws.services.rds.AmazonRDSClient.doInvoke( AmazonRDSClient.java:6357) ~[aws-java-sdk-rds-1.11.319.jar!/:na] 在 com.amazonaws.services.rds.AmazonRDSClient.invoke(AmazonRDSClient.java:6333) ~[aws-java-sdk-rds-1.11.319.jar!/:na] 在 com.amazonaws.services.rds.AmazonRDSClient.executeDescribeDBInstances(AmazonRDSClient.java:2999) ~[aws-java-sdk-rds-1.11.319.jar!/:na] 在 com.amazonaws.services.rds.AmazonRDSClient.describeDBInstances(AmazonRDSClient.java:2974) ~[aws-java-sdk-rds-1.11.319.jar!/:na] 在 org.springframework.cloud.aws.jdbc.rds.AmazonRdsDataSourceFactoryBean.getDbInstance(AmazonRdsDataSourceFactoryBean.java:167) ~[spring-cloud-aws-jdbc-1.0.4.RELEASE.jar!/:1.0.4.RELEASE] 在 org.springframework.cloud.aws.jdbc.rds.AmazonRdsDataSourceFactoryBean.createDataSourceInstance(AmazonRdsDataSourceFactoryBean.java:151) ~[spring-cloud-aws-jdbc-1.0.4.RELEASE.jar!/:1.0.4.RELEASE] 在 org.springframework.cloud.aws.jdbc.rds.AmazonRdsDataSourceFactoryBean.createInstance(AmazonRdsDataSourceFactoryBean.java:129) ~[spring-cloud-aws-jdbc-1.0.4.RELEASE.jar!/:1.0.4.RELEASE] 在 org.springframework.cloud.aws.jdbc.rds.AmazonRdsDataSourceFactoryBean.createInstance(AmazonRdsDataSourceFactoryBean.java:45) ~[spring-cloud-aws-jdbc-1.0.4.RELEASE.jar!/:1.0.4.RELEASE] 在 org.springframework.beans.factory.config.AbstractFactoryBean.afterPropertiesSet(AbstractFactoryBean.java:134) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] ...省略了44个常用框架 引起:javax.net.ssl.SSLException:不支持的记录版本未知-0.0 在 sun.security.ssl.InputRecord.checkRecordVersion(InputRecord.java:552) ~[na:1.8.0_131] 在 sun.security.ssl.InputRecord.readV3Record(InputRecord.java:565) ~[na:1.8.0_131] 在 sun.security.ssl.InputRecord.read(InputRecord.java:529) ~[na:1.8.0_131] 在 sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:983) ~[na:1.8.0_131] 在 sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1385) ~[na:1.8.0_131] 在 sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1413) ~[na:1.8.0_131] 在 sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1397) ~[na:1.8.0_131] 在 org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:394) ~[httpclient-4.5.1.jar!/:4.5.1] 在 org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:353) ~[httpclient-4.5.1.jar!/:4.5.1] 在 com.amazonaws.http.conn.ssl.SdkTLSSocketFactory.connectSocket(SdkTLSSocketFactory.java:132) ~[aws-java-sdk-core-1.11.319.jar!/:na] 在 org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:134) ~[httpclient-4.5.1.jar!/:4.5.1] 在 org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353) ~[httpclient-4.5.1.jar!/:4.5.1] 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131] 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131] 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131] 在 java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131] 在 com.amazonaws.http.conn.ClientConnectionManagerFactory$Handler.invoke(ClientConnectionManagerFactory.java:76) ~[aws-java-sdk-core-1.11.319.jar!/:na] 在 com.amazonaws.http.conn.$Proxy44.connect(Unknown Source) ~[na:na] 在 org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380) ~[httpclient-4.5.1.jar!/:4.5.1] 在 org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236) ~[httpclient-4.5.1.jar!/:4.5.1] 在 org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184) ~[httpclient-4.5.1.jar!/:4.5.1] 在 org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184) ~[httpclient-4.5.1.jar!/:4.5.1] 在 org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82) ~[httpclient-4.5.1.jar!/:4.5.1] 在 org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55) ~[httpclient-4.5.1.jar!/:4.5.1] 在 com.amazonaws.http.apache.client.impl.SdkHttpClient.execute(SdkHttpClient.java:72) ~[aws-java-sdk-core-1.11.319.jar!/:na] 在 com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1238) ~[aws-java-sdk-core-1.11.319.jar!/:na] 在 com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1058) ~[aws-java-sdk-core-1.11.319.jar!/:na] ...省略了61个常用框架

Exception in thread "main" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:62)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:54)
        ... 1 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.sql.DataSource org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.dataSource; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '$db-instance-identifier': Invocation of init method failed; nested exception is com.amazonaws.SdkClientException: Unable to execute HTTP request: Unsupported record version Unknown-0.0
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
        at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:368)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
        at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1054)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:829)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766)
        at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1180)
        at com.miss.equipoptimization.Application.main(Application.java:11)
        ... 6 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.sql.DataSource org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.dataSource; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '$db-instance-identifier': Invocation of init method failed; nested exception is com.amazonaws.SdkClientException: Unable to execute HTTP request: Unsupported record version Unknown-0.0
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573)
        at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
        ... 32 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '$db-instance-identifier': Invocation of init method failed; nested exception is com.amazonaws.SdkClientException: Unable to execute HTTP request: Unsupported record version Unknown-0.0
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545)
        ... 34 more
Caused by: com.amazonaws.SdkClientException: Unable to execute HTTP request: Unsupported record version Unknown-0.0
        at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleRetryableException(AmazonHttpClient.java:1116)
        at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1066)
        at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:743)
        at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:717)
        at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:699)
        at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:667)
        at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:649)
        at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:513)
        at com.amazonaws.services.rds.AmazonRDSClient.doInvoke(AmazonRDSClient.java:6357)
        at com.amazonaws.services.rds.AmazonRDSClient.invoke(AmazonRDSClient.java:6333)
        at com.amazonaws.services.rds.AmazonRDSClient.executeDescribeDBInstances(AmazonRDSClient.java:2999)
        at com.amazonaws.services.rds.AmazonRDSClient.describeDBInstances(AmazonRDSClient.java:2974)
        at org.springframework.cloud.aws.jdbc.rds.AmazonRdsDataSourceFactoryBean.getDbInstance(AmazonRdsDataSourceFactoryBean.java:167)
        at org.springframework.cloud.aws.jdbc.rds.AmazonRdsDataSourceFactoryBean.createDataSourceInstance(AmazonRdsDataSourceFactoryBean.java:151)
        at org.springframework.cloud.aws.jdbc.rds.AmazonRdsDataSourceFactoryBean.createInstance(AmazonRdsDataSourceFactoryBean.java:129)
        at org.springframework.cloud.aws.jdbc.rds.AmazonRdsDataSourceFactoryBean.createInstance(AmazonRdsDataSourceFactoryBean.java:45)
        at org.springframework.beans.factory.config.AbstractFactoryBean.afterPropertiesSet(AbstractFactoryBean.java:134)        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
        ... 44 more
Caused by: javax.net.ssl.SSLException: Unsupported record version Unknown-0.0

        at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:983)
        at 

【问题讨论】:

【参考方案1】:

使用您提供的格式阅读整个堆栈跟踪有点困难。

我会说您的代码似乎无法连接到 RDS 实例,根本原因是:

com.amazonaws.SdkClientException:无法执行 HTTP 请求:不支持的记录版本 Unknown-0.0

你不妨看看:Accessing RDS With SSL - Unsupported record version Unknown-0.0

至于为什么它可能在 docker 之外运行而在 docker 内部运行时无法运行,可能是默认情况下,某些 AWS SDK 代码在主机上运行时可能会从您的主目录中获取您的 AWS 凭证,例如~/.aws/credentials 例如。见:https://docs.aws.amazon.com/cli/latest/userguide/cli-config-files.html

在 docker 中运行时,我认为您没有挂载此目录或向应用程序提供凭据。

【讨论】:

嗨@David Goate,我的凭据存在于 application.properties 文件中。 FROM openjdk:8-jdk-alpine ADd target/rulecreation-0.1.0.jar rulecreation-0.1.0.jar EXPOSE 2000 ENTRYPOINT ["java", "-jar", "rulecreation-0.1.0.jar"] 引起:org.springframework.beans.factory.BeanCreationException:创建名为“$ db-instance-identifier”的bean时出错:调用init方法失败;原因:javax.net.ssl.SSLException:unsupported record version Unknown-0.0 at sun.security.ssl.InputRecord.checkRecordVersion(InputRecord.java:552) ~[na:1.8.0_131] 可能是 JDK 中的密码/SSL/TLS 支持有所不同。在您的 dockerfile 中,您从 alpine 上的 JDK8 运行。您在 JAR 运行正常的主机上本地使用什么操作系统和版本?如果可能的话,我会首先尝试在 dockerfile 中使用相同的 java 版本和操作系统类型来模仿它。 嗨 @David Goate 在运行 jar 时使用 windows 10 的 windows 环境。 java -version 在主机上的输出是什么? java version "1.8.0_171" Java(TM) SE Runtime Environment (build 1.8.0_171-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)

以上是关于使用 Spring Boot 代码运行 docker 容器的主要内容,如果未能解决你的问题,请参考以下文章

Docker 容器整合 Spring Boot 应用

如何将主机上运行的 Spring Boot 应用程序连接到 Docker 上运行的 Postgresql?

IDEA快速部署Spring Boot 项目到Docker

Vaadin Flow 是不是支持 Spring-Boot Native

使用 Spring Boot 代码运行 docker 容器

企业级spring-boot案例-Spring Boot 启动时的运行方法