在支持Java8的应用程序上从SpringBoot1迁移到SpringBoot2之后,启动时我遇到了运行缓慢的问题。
启动需要35-40分钟,在一个名为'tomcatPoolDataSourceMetadataProvider'的单个bean上大约需要15分钟。
07/08/2019 15:46:05.382调试 org.springframework.beans.factory.support.DefaultListableBeanFactory: [main] [{}]-通过bean名称按类型自动装配 'org.springframework.boot.actuate.autoconfigure.metrics.jdbc.DataSourcePoolMetricsAutoConfiguration $ DataSourcePoolMetadataMetricsConfiguration' 通过构造函数到名为“ tomcatPoolDataSourceMetadataProvider”的bean 07/08/2019 16:00:03.649调试 org.springframework.beans.factory.support.DefaultListableBeanFactory: [main] [{}]-创建单例bean的共享实例 'org.springframework.boot.actuate.autoconfigure.metrics.jdbc.DataSourcePoolMetricsAutoConfiguration'
import com.expedia.lodging.booking.metrics.annotation.EnableApplicationMetrics;
import expedia.content.solutions.metrics.spring.EnableMetrics;
import expedia.content.solutions.poke.spring.support.EnablePoke;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.autoconfigure.metrics.jdbc.DataSourcePoolMetricsAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ImportResource;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.servlet.DispatcherServlet;
@SpringBootApplication(exclude = {DataSourcePoolMetricsAutoConfiguration.class})
@ImportResource(locations = {"classpath:spring-config.xml"})
@EnableCaching(proxyTargetClass = true)
@EnableScheduling
@EnablePoke
@EnableMetrics
@EnableApplicationMetrics
public class Application {
@Value("${http.port}")
private int httpPort;
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Bean
public ServletRegistrationBean servletRegistrationBean(DispatcherServlet dispatcherServlet) {
ServletRegistrationBean register = new ServletRegistrationBean(dispatcherServlet);
register.addUrlMappings("/*", "/ping"); // Allow root level ping.
return register;
}}