当前位置: 首页 > 知识库问答 >
问题:

停止Spring Boot应用程序的启动,直到spring cloud config server启动

商畅
2023-03-14

我试图运行我的spring boot应用程序,设置了以下属性,我希望它继续重试从配置服务器加载属性50次,在任何两次尝试之间等待6秒,即使在此之后,它不能连接到配置服务器,它应该恢复启动或退出(我对重试后spring boot能够做的事情无所谓)。但它似乎并不像预期的那样表现。

我的启动命令-

java -jar -Dspring.application.name=maas-gateway -Dspring.cloud.config.uri=http://localhost:8888 -Dspring.cloud.config.failFast=false -Dspring.cloud.config.retry.initialInterval=5000 -Dspring.cloud.config.retry.maxInterval=7000 -Dspring.cloud.config.retry.maxAttempts=50 maas-gateway-1.0-SNAPSHOT.jar
    2017-10-06 09:55:05.881  INFO [] 3598 --- [                main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@53e25b76: startup date [Fri Oct 06 09:55:05 EDT 2017]; root of context hierarchy
    2017-10-06 09:55:06.136  INFO [] 3598 --- [                main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
    2017-10-06 09:55:06.166  INFO [] 3598 --- [                main] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [class org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$bbc9d7cf] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
      __  __              _____        _____       _
     |  \/  |            / ____|      / ____|     | |
     | \  / | __ _  __ _| (___ ______| |  __  __ _| |_ _____      ____ _ _   _
     | |\/| |/ _` |/ _` |\___ \______| | |_ |/ _` | __/ _ \ \ /\ / / _` | | | |
     | |  | | (_| | (_| |____) |     | |__| | (_| | ||  __/\ V  V / (_| | |_| |
     |_|  |_|\__,_|\__,_|_____/       \_____|\__,_|\__\___| \_/\_/ \__,_|\__, |
                                                                          __/ |
                                                                         |___/
    2017-10-06 09:55:06.494  INFO [] 3598 --- [                main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at: http://localhost:8888
    2017-10-06 09:55:06.579  WARN [] 3598 --- [                main] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/maas-gateway/default": Connection refused; nested exception is java.net.ConnectException: Connection refused
    2017-10-06 09:55:06.580  INFO [] 3598 --- [                main] com.solace.maas.Application              : No active profile set, falling back to default profiles: default
    2017-10-06 09:55:06.601  INFO [] 3598 --- [                main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@2ed94a8b: startup date [Fri Oct 06 09:55:06 EDT 2017]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@53e25b76
    2017-10-06 09:55:08.889  INFO [] 3598 --- [                main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'getManagerExecutorService' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=gatewayServiceConfiguration; factoryMethodName=getManagerExecutorService; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/solace/maas/gateway/configuration/GatewayServiceConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=iamServiceConfiguration; factoryMethodName=getManagerExecutorService; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/solace/maas/iam/configuration/IamServiceConfiguration.class]]
    2017-10-06 09:55:08.890  INFO [] 3598 --- [                main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'getMaasProperties' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=gatewayServiceConfiguration; factoryMethodName=getMaasProperties; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/solace/maas/gateway/configuration/GatewayServiceConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=iamServiceConfiguration; factoryMethodName=getMaasProperties; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/solace/maas/iam/configuration/IamServiceConfiguration.class]]
    2017-10-06 09:55:08.898  INFO [] 3598 --- [                main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'getManagerExecutorService' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=iamServiceConfiguration; factoryMethodName=getManagerExecutorService; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/solace/maas/iam/configuration/IamServiceConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=signupManagerConfiguration; factoryMethodName=getManagerExecutorService; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/solace/maas/signupManager/configuration/SignupManagerConfiguration.class]]
    2017-10-06 09:55:09.126  INFO [] 3598 --- [                main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'managementServletContext' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.actuate.autoconfigure.EndpointWebMvcHypermediaManagementContextConfiguration; factoryMethodName=managementServletContext; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/actuate/autoconfigure/EndpointWebMvcHypermediaManagementContextConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration; factoryMethodName=managementServletContext; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfiguration.class]]
    2017-10-06 09:55:09.750  WARN [] 3598 --- [                main] o.s.c.a.ConfigurationClassPostProcessor  : Cannot enhance @Configuration bean definition 'refreshScope' since its singleton instance has been created too early. The typical cause is a non-static @Bean method with a BeanDefinitionRegistryPostProcessor return type: Consider declaring such methods as 'static'.
    2017-10-06 09:55:09.992  INFO [] 3598 --- [                main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=27bcc9d7-c3a9-3801-b696-3f3650ee7946
    2017-10-06 09:55:10.038  INFO [] 3598 --- [                main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
    2017-10-06 09:55:10.137  INFO [] 3598 --- [                main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.sleuth.instrument.async.AsyncDefaultAutoConfiguration$DefaultAsyncConfigurerSupport' of type [class org.springframework.cloud.sleuth.instrument.async.AsyncDefaultAutoConfiguration$DefaultAsyncConfigurerSupport$$EnhancerBySpringCGLIB$$dcf17295] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    2017-10-06 09:55:10.237  INFO [] 3598 --- [                main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$9fafd4d2] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    2017-10-06 09:55:10.467  INFO [] 3598 --- [                main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration' of type [class org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration$$EnhancerBySpringCGLIB$$385d9d0c] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    2017-10-06 09:55:10.486  INFO [] 3598 --- [                main] trationDelegate$BeanPostProcessorChecker : Bean 'objectPostProcessor' of type [class org.springframework.security.config.annotation.configuration.AutowireBeanFactoryObjectPostProcessor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    2017-10-06 09:55:10.494  INFO [] 3598 --- [                main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler@736d6a5c' of type [class org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    2017-10-06 09:55:10.506  INFO [] 3598 --- [                main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration' of type [class org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration$$EnhancerBySpringCGLIB$$5d323fbe] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    2017-10-06 09:55:10.571  INFO [] 3598 --- [                main] trationDelegate$BeanPostProcessorChecker : Bean 'methodSecurityMetadataSource' of type [class org.springframework.security.access.method.DelegatingMethodSecurityMetadataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    2017-10-06 09:55:10.606  INFO [] 3598 --- [                main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.netflix.metrics.MetricsInterceptorConfiguration$MetricsRestTemplateConfiguration' of type [class org.springframework.cloud.netflix.metrics.MetricsInterceptorConfiguration$MetricsRestTemplateConfiguration$$EnhancerBySpringCGLIB$$d1dc7b13] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    2017-10-06 09:55:10.659  INFO [] 3598 --- [                main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [class org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$bbc9d7cf] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    2017-10-06 09:55:11.342  INFO [] 3598 --- [                main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
    2017-10-06 09:55:11.353  INFO [] 3598 --- [                main] o.apache.catalina.core.StandardService   : Starting service Tomcat
    2017-10-06 09:55:11.354  INFO [] 3598 --- [                main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.6
    2017-10-06 09:55:11.429  INFO [] 3598 --- [ocalhost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
    2017-10-06 09:55:11.429  INFO [] 3598 --- [ocalhost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 4828 ms
    2017-10-06 09:55:12.903 ERROR [] 3598 --- [ocalhost-startStop-1] o.s.b.c.embedded.tomcat.TomcatStarter    : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'iamServiceConfiguration': Unsatisfied dependency expressed through method 'setContentNegotationStrategy' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration': Unsatisfied dependency expressed through method 'setConfigurers' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter': Unsatisfied dependency expressed through constructor parameter 3; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration$$EnhancerBySpringCGLIB$$3067f332]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jacksonHttpMessageConverter' defined in class path resource [org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.hateoas.mvc.TypeConstrainedMappingJackson2HttpMessageConverter]: Factory method 'jacksonHttpMessageConverter' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'config' defined in class path resource [org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.rest.core.config.RepositoryRestConfiguration]: Factory method 'config' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'repositories' defined in class path resource [org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.repository.support.Repositories]: Factory method 'repositories' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userAttributeDAO': Cannot create inner bean '(inner bean)#60b53b0c' of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property 'entityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#60b53b0c': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Tomcat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
    2017-10-06 09:55:12.932  WARN [] 3598 --- [                main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
    2017-10-06 09:55:12.940 ERROR [] 3598 --- [                main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

如果您想要一个嵌入式数据库,请在类路径上放置一个受支持的数据库。如果要从特定配置文件加载数据库设置,则可能需要激活它(当前没有配置文件处于活动状态)。

共有1个答案

尉迟国发
2023-03-14

添加spring-retry作为依赖项。

 类似资料:
  • 我们的webstart应用程序(不是小程序)遇到了奇怪的启动问题。 启动应用程序会显示应用程序启动屏幕,但javaws进程会在不久后终止,不会在对话框、java控制台或日志文件中显示任何错误消息。javaws似乎只是在实际启动实际应用程序之前停止。无论用户尝试从桌面快捷方式还是从网页启动应用程序,都无关紧要。当从本地计算机使用javaw运行而无需webstart时,相同的应用程序可以正常工作。 应

  • 是否有一种干净的方法来检测spring启动应用程序何时停止,并在停止之前执行一些操作?一种停止服务的CommandLineRunner 提前谢谢

  • 使用spring-boot时,一切工作都很好。尽管如此,在spring-boot中已删除了注释和。我试图将代码重构为新版本,但我做不到。对于以下测试,我的应用程序在测试之前没有启动,http://localhost:8080返回404: 如何重构测试以使其在Spring-Boot1.5中工作?

  • 有一个很奇怪的问题...有一次我打开我的项目,并注意到我没有机会从工作室推出app...黑色三角形唱罩禁用 但是,如果我构建apk文件并使用adb命令安装它,它就可以工作。 我已经尝试删除和下载新的Android Studio,但没有任何改变... 我的插件 我的配置

  • 正在启动lib/main。调试模式下sdk gphone arm64上的dart。。。正在运行Gradle任务“assembleDebug”。。。✓ 构建/应用/输出/颤振apk/应用调试。阿普克。安装build/app/outputs/flatter apk/app。apk。。。E/AndroidRuntime(22444):致命异常:主E/AndroidRuntime(22444):进程:co

  • 我的应用程序无法启动,因为错误膨胀了类ImageButton,因此手机显示“应用程序已停止”等。我正在使用Firebase测试实验室来调试问题 错误发生在三星设备上,特别是A20、s7 Edge、s7(使用firebase测试时出现相同问题) 我刚接触Android系统,曾尝试过谷歌的许多解决方案,因此至今没有一个能奏效 这里是Firebase的错误报告 这是XML 这是错误代码的第117行