Menu

Your Spring Boot App Starts in 3 Seconds. Here's How
πŸ“°

Your Spring Boot App Starts in 3 Seconds. Here's How

DEV Community: javaΒ·Ravindra SinghΒ·3 days ago
#AStyrnhp
#devtojava#devto#dev#spring#boot
Long article (1511 words) β€” no AI summary yet.
Reading 0:00
15s threshold

You click Run. The console fills with lines you don't read. A few seconds later, one line appears that you do read: Started DemoApplication in 2.9 seconds . Your API is live.

So what happened in those 3 seconds? A Spring Boot application is a normal Java program whose main() hands control to Spring. Spring then finds your classes, turns them into objects called beans, plugs them together, sets up a web server for you, and starts listening on port 8080.

That's the whole story. Now let's slow it down, because once you can see these steps, the scary startup errors stop being scary.

A tiny app to follow

Here is a small bookshop app. Three classes, all in the package com.example.demo (or packages below it):

@SpringBootApplication public class DemoApplication { public static void main ( String [ ] args ) { SpringApplication . run ( DemoApplication . class , args ) ; } }

@Service class BookService { List < String > all ( ) { return List .…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.