注解方法上的@PostConstruct无法在springboot应用程序启动时启动

时间:2019-03-07 09:59:26

标签: java azure spring-boot

EventListener来侦听Azure事件中心,需要在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();
        }

    }
        }

要在春季启动应用程序启动时启动它,我在类中添加了以下内容

@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();

    }

}

1 个答案:

答案 0 :(得分:0)

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

将其移至@Configuration类,并确保正确扫描EventProcessor Component

当前有效的@Autowire实例的AzureProperties将会失败。
您将拥有empty / 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);
    }
}