Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/321.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在SpringApplication.run()方法完成之前有很大的延迟_Java_Spring_Spring Boot_Spring Bean_Postconstruct - Fatal编程技术网

Java 在SpringApplication.run()方法完成之前有很大的延迟

Java 在SpringApplication.run()方法完成之前有很大的延迟,java,spring,spring-boot,spring-bean,postconstruct,Java,Spring,Spring Boot,Spring Bean,Postconstruct,我有以下课程: package org.edgexfoundry.pkg; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springf

我有以下课程:

package org.edgexfoundry.pkg;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.scheduling.annotation.EnableAsync;

@SpringBootApplication
@EnableAsync
@EnableDiscoveryClient
public class Application {
  public static ConfigurableApplicationContext ctx;

  public static void main(String[] args) {
    ctx = SpringApplication.run(Application.class, args);
    System.out.println("WELCOME!");
  }
在同一项目的另一类中,我有:

@ImportResource("spring-config.xml")
public class BaseService {
    @PostConstruct
    private void postConstructInitialize() {
        logger.debug("post construction initialization");
    }
}
其中,我的
spring config.xml
文件是:

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:amq="http://activemq.apache.org/schema/core" xmlns:jms="http://www.springframework.org/schema/jms"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context.xsd">

    <context:property-placeholder
        location="classpath:*.properties" />

    <bean class="org.edgexfoundry.pkg.HeartBeat" />
    <context:component-scan base-package="org.edgexfoundry.pkg" />
    <context:component-scan base-package="org.edgexfoundry" />

</beans> 
当我运行项目时,我得到以下输出:

BySpringCGLIB$$1088c4ff] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
/*******************************************************************************
 * Copyright 2017, Dell, Inc.  All Rights Reserved.
 ******************************************************************************/
WELCOME!

2019-04-02 12:50:24.574  INFO 1 --- [           main] org.edgexfoundry.pkg.Application         : No active profile set, falling back to default profiles: default
过了很长时间(大约8分钟),我得到了最后一行:

2019-04-02 12:57:04.611 DEBUG 1 --- [           main] org.edgexfoundry.pkg.BaseService         : post construction initialization

与此同时正在做什么?为什么
@PostConstruct
方法需要这么多时间来运行,即为什么
SpringApplication.run()
方法完成得这么晚?有什么想法吗?

启动速度明显较慢的一个原因是默认实现扫描网络接口以提供额外的系统熵源

可以通过注册自己的或使用


Java中的(快速)和安全伪随机数生成也是其中之一。

启动速度明显较慢的一个原因是默认实现扫描网络接口以提供额外的系统熵源

可以通过注册自己的或使用


Java中的(快速)和安全伪随机数生成主题中还有一个问题。

可能日志是在不同的日志文件中编写的,例如catalina.out?@user7294900您的确切意思是什么?我工作的文件夹中没有生成任何文件。。。另外,根据这个线程:,spring引导在控制台中输出…因为您使用的是
@EnableDiscoveryClient
,所以我认为您的应用程序试图连接到discovery server,这可能需要一段时间time@Ivan我有另一个与此相同的项目,但没有此注释。不过,这需要同样的时间……在
BaseService
之上还有其他注释吗?就目前情况而言,我不知道Spring会如何将您的
BaseService
作为一个bean来获取。可能日志是在不同的日志文件中编写的,例如catalina.out?@user7294900您的确切意思是什么?我工作的文件夹中没有生成任何文件。。。另外,根据这个线程:,spring引导在控制台中输出…因为您使用的是
@EnableDiscoveryClient
,所以我认为您的应用程序试图连接到discovery server,这可能需要一段时间time@Ivan我有另一个与此相同的项目,但没有此注释。不过,这需要同样的时间……在
BaseService
之上还有其他注释吗?就目前的情况而言,我不知道Spring如何将您的
BaseService
作为一个bean来接受。
2019-04-02 12:57:04.611 DEBUG 1 --- [           main] org.edgexfoundry.pkg.BaseService         : post construction initialization