@PostConstruct 注释在方法上没有在 springboot 应用程序启动时启动

代码

监听azure事件中心的EventListener需要在springboot应用程序启动时启动 有问题的类是

       @Component
        @EnableConfigurationProperties(AzureProperties.class)
        public class EventProcessor {
        private static final Logger LOGGER = LoggerFactory.getLogger(EventProcessor.class);

        @Autowired
        private AzureProperties azureProperties;

            public void startProcess() throws InterruptedException, ExecutionException {
                System.out.println("----------------------------------in Post construct---------------------");
                LOGGER.info(
                        "-------------------------------------Starting in post constriuct----------------------------------");
                EventProcessorHost host = new EventProcessorHost(
                        EventProcessorHost
                                .createHostName(azureProperties.getHostNamePrefix()),
                        azureProperties.getEventHubName(),
                        azureProperties.getConsumerGroupName(),
                        azureProperties.getEventHubConnectionString(),
                        azureProperties.getStorageConnectionString(),
                        azureProperties.getStorageContainerName());
                EventProcessorOptions options = new EventProcessorOptions();
                host.registerEventProcessor(AzureEventHub.class, options).get();

            }
    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        try {
            startProcess();
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ExecutionException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }
        }

为了在 spring boot 应用程序启动时启动它,我在类中添加了以下内容

@PostConstruct
public void init() {
    System.out.println("----------------------------------in INIT construct---------------------");
    try {
        startProcess();
    } catch (InterruptedException e) {

        e.printStackTrace();
    } catch (ExecutionException e) {

        e.printStackTrace();
    }
}

但是,在应用程序启动后,它甚至不会在控制台中打印或显示记录器。@postConstruct 不应该触发这个吗?

主要类是

@EnableDatabaseManagement
@SpringBootApplication(scanBasePackages={"com.package"})
@PropertySource(value = "classpath:/secure.properties", ignoreResourceNotFound = true)
public class Application {
    public static void main(String[] args) throws EventHubException, IOException, InterruptedException, ExecutionException {
        TimeZone.setDefault(TimeZone.getTimeZone("Etc/UCT"));
        DateTimeZone.setDefault(DateTimeZone.forID("Etc/UCT"));
        SpringApplication.run(Application.class, args);
    }

我在这里得到的日志是

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::       (v1.5.15.RELEASE)

2019-03-07 23:49:44.025  INFO 6456 --- [           main] c.o.c.s.s.sandboxmanager.Application     : Starting Application on 
2019-03-07 23:49:44.028  INFO 6456 --- [           main] c.o.c.s.s.sandboxmanager.Application     : No active profile set, falling back to default profiles: default
2019-03-07 23:49:44.093  INFO 6456 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@7995092a: startup date [Thu Mar 07 23:49:44 UTC 2019]; root of context hierarchy
2019-03-07 23:49:44.981  INFO 6456 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'xxxx' with a different definition: replacing [Generic bean: class [com.xxxx.xxxx.clientrouter.xxxxx]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in URL [] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=clientContextExtractionConfiguration; factoryMethodName=xxxx; initMethodName=null; destroyMethodName=(inferred); defined in class path resource 
2019-03-07 23:49:44.990  INFO 6456 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'jerseyConfigInitBeanPostProcessor' with a different definition: replacing [Generic bean: class [com.xxx.xxxx.jersey.JerseyConfigInitBeanPostProcessor]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in URL [jar:file:/E:/.m2/repository/com/xxxx/cloud/lib/rest-lib/1.7.8/rest-lib-1.7.8.jar!/com/xxxx/cloud/lib/rest/jersey/JerseyConfigInitBeanPostProcessor.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=jerseyIntegrationConfiguration; factoryMethodName=jerseyConfigInitBeanPostProcessor; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/xxxx/cloud/lib/rest/jersey/JerseyIntegrationConfiguration.class]]
2019-03-07 23:49:45.497  INFO 6456 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2019-03-07 23:49:45.537  INFO 6456 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesValidator' of type [] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-03-07 23:49:45.686  INFO 6456 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$13d316d7] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-03-07 23:49:45.756  INFO 6456 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$JacksonObjectMapperConfiguration' of type [org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$JacksonObjectMapperConfiguration$$EnhancerBySpringCGLIB$$6f669668] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-03-07 23:49:45.764  INFO 6456 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$JacksonObjectMapperBuilderConfiguration' of type [org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$JacksonObjectMapperBuilderConfiguration$$EnhancerBySpringCGLIB$$21b35881] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-03-07 23:49:45.777  INFO 6456 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$Jackson2ObjectMapperBuilderCustomizerConfiguration' of type [org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$Jackson2ObjectMapperBuilderCustomizerConfiguration$$EnhancerBySpringCGLIB$$dcca3e70] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-03-07 23:49:45.795  INFO 6456 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'spring.jackson-org.springframework.boot.autoconfigure.jackson.JacksonProperties' of type [org.springframework.boot.autoconfigure.jackson.JacksonProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-03-07 23:49:45.802  INFO 6456 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'standardJacksonObjectMapperBuilderCustomizer' of type [org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$Jackson2ObjectMapperBuilderCustomizerConfiguration$StandardJackson2ObjectMapperBuilderCustomizer] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-03-07 23:49:45.835  INFO 6456 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$JodaDateTimeJacksonConfiguration' of type [org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$JodaDateTimeJacksonConfiguration$$EnhancerBySpringCGLIB$$a6d69ce5] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-03-07 23:49:45.839  INFO 6456 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'jodaDateTimeSerializationModule' of type [com.fasterxml.jackson.databind.module.SimpleModule] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-03-07 23:49:45.842  INFO 6456 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration' of type [org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$$EnhancerBySpringCGLIB$$517233f7] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-03-07 23:49:45.853  INFO 6456 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'jsonComponentModule' of type [org.springframework.boot.jackson.JsonComponentModule] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-03-07 23:49:45.857  INFO 6456 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.data.web.config.SpringDataJacksonConfiguration' of type [org.springframework.data.web.config.SpringDataJacksonConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-03-07 23:49:45.863  INFO 6456 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'jacksonGeoModule' of type [org.springframework.data.geo.GeoModule] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-03-07 23:49:45.866  INFO 6456 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'jacksonObjectMapperBuilder' of type [org.springframework.http.converter.json.Jackson2ObjectMapperBuilder] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-03-07 23:49:45.891  INFO 6456 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'jacksonObjectMapper' of type [com.fasterxml.jackson.databind.ObjectMapper] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-03-07 23:49:45.906  INFO 6456 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'jerseyIntegrationConfiguration' of type [com.xxxx.xxxx.jersey.JerseyIntegrationConfiguration$$EnhancerBySpringCGLIB$$a7b38252] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-03-07 23:49:45.959  INFO 6456 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'jacksonJaxbJsonProvider' of type [com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-03-07 23:49:45.972  INFO 6456 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'jerseyConfig' of type [org.glassfish.jersey.server.ResourceConfig] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-03-07 23:49:46.352  INFO 6456 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2019-03-07 23:49:46.380  INFO 6456 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2019-03-07 23:49:46.380  INFO 6456 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.15
2019-03-07 23:49:46.540  INFO 6456 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2019-03-07 23:49:46.541  INFO 6456 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2451 ms
2019-03-07 23:49:46.837  INFO 6456 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'corsFilter' to: [/*]
2019-03-07 23:49:46.838  INFO 6456 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'activityLoggingFilter' to: [/*]
2019-03-07 23:49:46.838  INFO 6456 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'xxxx' to: [/*]
2019-03-07 23:49:46.838  INFO 6456 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2019-03-07 23:49:46.838  INFO 6456 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2019-03-07 23:49:46.838  INFO 6456 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2019-03-07 23:49:46.838  INFO 6456 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2019-03-07 23:49:46.839  INFO 6456 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*]
2019-03-07 23:49:46.839  INFO 6456 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'org.glassfish.jersey.server.ResourceConfig' to [/*]
2019-03-07 23:49:46.840  INFO 6456 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
2019-03-07 23:50:05.838  INFO 6456 --- [           main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2019-03-07 23:50:05.857  INFO 6456 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
    name: default
    ...]
2019-03-07 23:50:05.934  INFO 6456 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate Core {5.1.0.Final}
2019-03-07 23:50:05.936  INFO 6456 --- [           main] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
2019-03-07 23:50:05.938  INFO 6456 --- [           main] org.hibernate.cfg.Environment            : HHH000021: Bytecode provider name : javassist
2019-03-07 23:50:05.983  INFO 6456 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2019-03-07 23:50:06.120  INFO 6456 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.SQLServer2012Dialect
2019-03-07 23:50:08.214  INFO 6456 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2019-03-07 23:50:08.431  INFO 6456 --- [           main] .l.r.j.JerseyConfigInitBeanPostProcessor : Registering com.xxxx.xxxx.monitoring.HealthEndpoint
2019-03-07 23:50:08.589  INFO 6456 --- [           main] .l.r.j.JerseyConfigInitBeanPostProcessor :
2019-03-07 23:50:08.622  INFO 6456 --- [           main] .a.p.AzureAdAuthenticationResultProvider : Initializing Azure Active Directory authentication for
2019-03-07 23:50:08.652  INFO 6456 --- [           main] c.o.c.l.r.c.RestLibCachingConfiguration  : Using default rest-lib EhCache configuration from classpath: ehCache-rest-lib.xml
2019-03-07 23:50:08.656  INFO 6456 --- [           main] o.s.c.ehcache.EhCacheManagerFactoryBean  : Initializing EhCache CacheManager 'restLibCacheManager'
2019-03-07 23:50:08.948  INFO 6456 --- [           main] .l.r.j.JerseyConfigInitBeanPostProcessor : Registering xxxx as REST endpoint
2019-03-07 23:50:09.201  INFO 6456 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@7995092a: startup date [Thu Mar 07 23:49:44 UTC 2019]; root of context hierarchy
2019-03-07 23:50:09.277  INFO 6456 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2019-03-07 23:50:09.278  INFO 6456 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2019-03-07 23:50:09.307  INFO 6456 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-03-07 23:50:09.307  INFO 6456 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-03-07 23:50:09.321  INFO 6456 --- [           main] .m.m.a.ExceptionHandlerExceptionResolver : Detected @ExceptionHandler methods in brokenPipeExceptionHandler
2019-03-07 23:50:09.347  INFO 6456 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-03-07 23:50:09.620  INFO 6456 --- [           main] b.a.s.AuthenticationManagerConfiguration : 



2019-03-07 23:50:09.681  INFO 6456 --- [           main] o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: OrRequestMatcher [requestMatchers=[Ant [pattern='/css/**'], Ant [pattern='/js/**'], Ant [pattern='/images/**'], Ant [pattern='/webjars/**'], Ant [pattern='/**/favicon.ico'], Ant [pattern='/error']]], []
2019-03-07 23:50:09.777  INFO 6456 --- [           main] o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: org.springframework.security.web.util.matcher.AnyRequestMatcher@1, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@369ad7da, org.springframework.security.web.context.SecurityContextPersistenceFilter@13c90c06, org.springframework.security.web.header.HeaderWriterFilter@3355168, org.springframework.security.web.authentication.logout.LogoutFilter@2830315f, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@553ce348, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter@365bfc5f, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@15f861ee, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@405d8a80, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@344f9467, org.springframework.security.web.session.SessionManagementFilter@580c17a0, org.springframework.security.web.access.ExceptionTranslationFilter@5ba184fc, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@6e364f1f]
2019-03-07 23:50:09.795  INFO 6456 --- [           main] o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: OrRequestMatcher [requestMatchers=[Ant [pattern='/**']]], [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@143413cd, org.springframework.security.web.context.SecurityContextPersistenceFilter@2b5f8e61, org.springframework.security.web.header.HeaderWriterFilter@56f9de3b, org.springframework.security.web.authentication.logout.LogoutFilter@6ec3d8e4, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@1aeff8ca, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@6ba0ee4a, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@73b0ed03, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@4b32465, org.springframework.security.web.session.SessionManagementFilter@6728370a, org.springframework.security.web.access.ExceptionTranslationFilter@38ef1a0a, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@4af70b83]
2019-03-07 23:50:10.002  INFO 6456 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2019-03-07 23:50:10.011  INFO 6456 --- [           main] o.s.c.support.DefaultLifecycleProcessor  : Starting beans in phase 2147483647
2019-03-07 23:50:10.054  INFO 6456 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2019-03-07 23:50:10.061  INFO 6456 --- [           main] c.o.c.s.s.sandboxmanager.Application     : Started Application in 26.379 seconds (JVM running for 26.819)

命令行运行程序类

   @Component
   public class EventProcessorRunner implements CommandLineRunner{

    private final EventProcessor processor; 

    EventProcessorRunner(final EventProcessor processor) {
       this.processor = processor;
    }

    @Override
    public void run(String... args) throws Exception {
        processor.startProcess();

    }

}
LppEdd

@EnableConfigurationProperties注释必须一起选择使用与@Configuration注解类,而不是用@Component的。这是我立即看到的一个问题。

将它移到一个@Configuration类中,并确保EventProcessor 组件被正确扫描。

目前@Autowire,有效AzureProperties实例的 将失败。
你将有空/null属性。


我不会使用@PostConstruct它,而是CommandLineRunner更适合。

@Component
class EventProcessorRunner implements CommandLineRunner {
    private final EventProcessor processor; 

    EventProcessorRunner(final EventProcessor processor) {
       this.processor = processor;
    }

    @Override
    public void run(final String... args) throws Exception {
        processor.startProcess();
    }
}

@SpringBootApplication批注已经提供了@ComponentScan引擎盖下。
你也可以添加@EnableConfigurationProperties

@SpringBootApplication
@EnableConfigurationProperties(AzureProperties.class)
@EnableDatabaseManagement
@PropertySource(value = "classpath:/secure.properties", ignoreResourceNotFound = true)
public class Application {
    public static void main(String[] args) throws EventHubException, IOException, InterruptedException, ExecutionException {
        TimeZone.setDefault(TimeZone.getTimeZone("Etc/UCT"));
        DateTimeZone.setDefault(DateTimeZone.forID("Etc/UCT"));
        SpringApplication.run(Application.class, args);
    }
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

在Bluemix上使用Liberty for Java的CloudFoundry / Springboot应用程序在启动时突然崩溃,几个月来代码没有任何变化

Flutter 应用程序在 iPhone 上启动时崩溃

启动时iOS 13上的应用程序黑屏

如果没有exe文件,如何使程序/应用程序小部件在启动时启动?

springboot @PostConstruct方法被调用两次

当应用程序通过启动应用程序启动时没有按钮点击声音

Springboot 2.3.x应用程序在启动时卡住

在嵌入式Linux设备(Beaglebone Black)上启动时启动QT应用程序

伴侣:在VPS上启动时启动Gui应用程序

简单的计数器应用程序在启动时崩溃,没有任何错误

当应用程序启动时,闪亮的单选按钮最初没有被渲染

当应用程序启动时项目没有更改时,itemChanged信号起作用

为什么我的 React Native 应用程序在启动时崩溃而没有任何错误?

Xamarin - android 空白应用程序在启动时停止,没有错误或警告

由于从推送通知启动时没有系统应用程序而终止

DP6 - 应用程序启动时没有 UI

Springboot 2 RSocket应用程序启动,然后立即停止,没有错误消息

我所有的应用程序在物理 iPhone 上启动时都崩溃了

尝试在现有Gradle项目上启动springboot应用程序时出现错误

非标准应用程序启动时在Unity Launcher上的两个图标

在真实设备上启动时,React-Native新鲜应用程序立即关闭

VirtualBox 上的 Android x86:应用程序在启动时崩溃

应用程序启动时将焦点放在PasswordBox上

添加 Root 密码并在启动时在 MongoDB Docker 容器上创建应用程序用户

企业(内部)Swift应用程序在iOS9上启动时退出

发布应用程序在棒棒糖上启动时崩溃

iOS 4应用程序在iOS 3.1.3上启动时崩溃:找不到符号:__NSConcreteStackBlock

推送服务启动时,Android上的解析应用程序占用40 MB

可以在应用程序启动时已经在运行的进程上使用EnableRaisingEvents吗?