DEV Community

V I N O T H
V I N O T H

Posted on

2 2 2 2 2

Spring Boot,Annotation

1.what is Spring Boot?
Spring Boot is a framework built on top of Spring Framework that simplifies the development of Java-based web applications and microservices. It eliminates the need for complex configurations and allows developers to quickly build and deploy applications with minimal setup.

2.key points of Spring
Spring Boot – Key Points πŸš€
βœ… Built on Spring Framework – Simplifies Java web and microservices development.
βœ… Auto-configuration – Reduces manual setup, configures beans automatically.
βœ… Embedded Servers – Comes with Tomcat, Jetty, or Undertow, no need for external servers.
βœ… Spring Boot Starters – Pre-configured dependencies for faster development.
βœ… Microservices Support – Ideal for cloud-based applications.
βœ… Spring Boot Actuator – Provides monitoring, metrics, and health checks.
βœ… Production-Ready – Has logging, exception handling, and security features.
βœ… Spring Initializr – Generates a project setup quickly (start.spring.io).
βœ… Simplified Deployment – Can be packaged as a JAR and run independently.

Example program

package com.example.demo;

import org.springframework.stereotype.Component;

@Component 
public class Engine {

//  String fuel1, fuel2;
//  public Engine(String fuel1, String fuel2) 
//  {
//      this.fuel1 = fuel1;
//      this.fuel2 = fuel2;
//  }

    public void Start() {
        System.out.println("Engine Started");
    }
}

Enter fullscreen mode Exit fullscreen mode

package com.example.demo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class Car {

@Autowired
Engine engine;

public static void main(String[] args) {

    // Car maruti = new Car();
    // maruti.drive();
}

public void drive() {
    // TODO Auto-generated method stub
    // Engine engine = new Engine("Petrol");
    engine.Start();

}
Enter fullscreen mode Exit fullscreen mode

}

package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
public class DemoApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext cac= 
        SpringApplication.run(DemoApplication.class, args);
        Car Bezn = cac.getBean(Car.class);
        Bezn.drive();
    }

}

Enter fullscreen mode Exit fullscreen mode

Output

. ____ _ __ _ _
/\ / ' __ _ ()_ __ __ _ \ \ \ \
( ( )_ | '_ | '| | ' \/ ` | \ \ \ \
\/ _)| |)| | | | | || (| | ) ) ) )
' |__| .|| ||| |_, | / / / /
=========||==============|_/=////

:: Spring Boot :: (v3.4.4)

2025-04-03T18:18:10.927+05:30 INFO 10662 --- [demo] [ restartedMain] com.example.demo.DemoApplication : Starting DemoApplication using Java 21.0.6 with PID 10662 (/home/neelakandan/Documents/workspace-spring-tool-suite-4-4.29.1.RELEASE/demo/target/classes started by neelakandan in /home/neelakandan/Documents/workspace-spring-tool-suite-4-4.29.1.RELEASE/demo)
2025-04-03T18:18:10.930+05:30 INFO 10662 --- [demo] [ restartedMain] com.example.demo.DemoApplication : No active profile set, falling back to 1 default profile: "default"
2025-04-03T18:18:10.973+05:30 INFO 10662 --- [demo] [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2025-04-03T18:18:10.973+05:30 INFO 10662 --- [demo] [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2025-04-03T18:18:11.812+05:30 INFO 10662 --- [demo] [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port 8080 (http)
2025-04-03T18:18:11.824+05:30 INFO 10662 --- [demo] [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2025-04-03T18:18:11.824+05:30 INFO 10662 --- [demo] [ restartedMain] o.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/10.1.39]
2025-04-03T18:18:11.850+05:30 INFO 10662 --- [demo] [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2025-04-03T18:18:11.851+05:30 INFO 10662 --- [demo] [ restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 876 ms
2025-04-03T18:18:12.163+05:30 INFO 10662 --- [demo] [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2025-04-03T18:18:12.183+05:30 INFO 10662 --- [demo] [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port 8080 (http) with context path '/'
2025-04-03T18:18:12.192+05:30 INFO 10662 --- [demo] [ restartedMain] com.example.demo.DemoApplication : Started DemoApplication in 1.585 seconds (process running for 1.88)
Engine Started
Enter fullscreen mode Exit fullscreen mode

Jetbrains image

Build Secure, Ship Fast

Discover best practices to secure CI/CD without slowing down your pipeline.

Read more

Top comments (0)

πŸ‘‹ Kindness is contagious

DEV works best when you're signed inβ€”unlocking a more customized experience with features like dark mode and personalized reading settings!

Okay