Chenhao
Chenhao

Reputation: 1

start a Spring boot Application on ubuntu but cost too much time

When i start my Spring Boot Application on Windows10 (within IDE), i can type the url in Chrome and get what i want immediatly.

However, when i start it on a ubuntu server, it will be 10 minutes or even half an hour until it works. I see no need for this and want to cut it.

(But when i start it, i can see "Started Application in 18.193 seconds (JVM running for 19.086)")

Of course, after serveral minutes, it works quite well.

The version is spring boot 1.4.2.

Is there any reasons for this?

Thanks a lot!

Upvotes: 0

Views: 629

Answers (1)

SkyWalker
SkyWalker

Reputation: 29150

Root cause analysis:

Component Scanning Slows Start-up

  1. It slows application start-up time. This will have a greater impact if you have a large application, or a large number of integration tests that need to start up the application to run.
  2. It may load beans you don't want or need.

Auto-Configuration Can Load More Than You Need

The @SpringBootApplication annotation implies the @EnableAutoConfiguration annotation. This enables auto-configuration. This can load components you don't need, slowing application start-up and increasing memory and CPU usage.

Resource Link: Spring Boot Performance


Solution Procedure:

You can enable DEBUG logging as simple as specifying --debug when starting the application from command line. You can also specify debug=true in your application.properties.

In addition, you can set the logging level in application.properties as given below:

logging.level.org.springframework.web: DEBUG
logging.level.org.hibernate: ERROR

If you detect an auto-configured module you don't want, it can be disabled. The docs for this can be found here: http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#using-boot-disabling-specific-auto-configuration

Resource Link: https://stackoverflow.com/a/35713866/2293534

Upvotes: 2

Related Questions