Spring Boot双重初始化

时间:2019-03-14 15:31:46

标签: java spring-boot

我遇到一个问题,其中我的ConfigurationProperties bean没有填充详细信息(或更正确地说,这些值被有效清除了)。我正在使用大量Spring片段,但尤其是Cloud Config,因为它在这里似乎最相关。我所看到的是,我的主要上下文正在刷新-并且在刷新时,即使以正确的方式获取属性定义(localhost:8081),bean的内容也正在以某种方式擦除。如果我在Binding类中设置一个断点,则第一次可以看到带有值的Bean,但是在第二个“循环”之后,所有字段/值均为null / zero / etc。这可能是由Spring插件的某种组合引起的吗?这是一个堆栈跟踪,似乎显示它在刷新上下文时在内部循环:

Thread [main] (Suspended (breakpoint at line 397 in SpringApplication)) 
                owns: AtomicBoolean  (id=277)  
                owns: DefaultBinderFactory  (id=278)     
                owns: Object  (id=67)
                /* How did I get here again? */
                SpringApplication.refreshContext(ConfigurableApplicationContext) line: 397        
                SpringApplication.run(String...) line: 316 
                SpringApplicationBuilder.run(String...) line: 139  
                DefaultBinderFactory.getBinderInstance(String) line: 250               
                DefaultBinderFactory.doGetBinder(String, Class<? extends T>) line: 174  
                DefaultBinderFactory.getBinder(String, Class<? extends T>) line: 120        
                BindingService.getBinder(String, Class<T>) line: 313          
                BindingService.bindProducer(T, String) line: 214 
                BindableProxyFactory.createAndBindOutputs(BindingService) line: 262   
                OutputBindingLifecycle.doStartWithBindable(Bindable) line: 55  
                268882147.accept(Object) line: not available       
                LinkedHashMap$LinkedValues.forEach(Consumer<? super V>) line: 608  
                OutputBindingLifecycle(AbstractBindingLifecycle).start() line: 47 
                OutputBindingLifecycle.start() line: 34    
                DefaultLifecycleProcessor.doStart(Map<String,Lifecycle>, String, boolean) line: 182            
                DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor, Map, String, boolean) line: 53   
                DefaultLifecycleProcessor$LifecycleGroup.start() line: 360             
                DefaultLifecycleProcessor.startBeans(boolean) line: 158 
                DefaultLifecycleProcessor.onRefresh() line: 122  
                AnnotationConfigServletWebServerApplicationContext(AbstractApplicationContext).finishRefresh() line: 893                
                AnnotationConfigServletWebServerApplicationContext(ServletWebServerApplicationContext).finishRefresh() line: 163               
                AnnotationConfigServletWebServerApplicationContext(AbstractApplicationContext).refresh() line: 552    
                AnnotationConfigServletWebServerApplicationContext(ServletWebServerApplicationContext).refresh() line: 142         
                SpringApplication.refresh(ApplicationContext) line: 775  
                SpringApplication.refreshContext(ConfigurableApplicationContext) line: 397         
                SpringApplication.run(String...) line: 316 
                SpringApplication.run(Class<?>[], String[]) line: 1260        
                SpringApplication.run(Class<?>, String...) line: 1248           
                MyApplication.main(String[]) line: 21      

0 个答案:

没有答案