Your First Spring Boot Application

A Spring Boot standalone application uses the @SpringBootApplication  annotation over a class with a main  method that will execute the application. The method call accepts two parameters — the class that actually contains the annotated @SpringBootApplication annotation and any application arguments. The ApplicationArguments interface allows you to access any application arguments.


Bean Components

We will use a simple bean class based on our previous examples:

package com.javajee.springboot;

import org.springframework.stereotype.Component;

class JJWriter {
    public void write() {
        System.out.println("Inside JJWriter's method write()");


Test Class (Main class)

A Spring Boot standalone application can be created using the @SpringBootApplication.

package com.javajee.springboot;

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

public class JJWriterMain {

    public static void main(String[] args) {
        ConfigurableApplicationContext context =, args);
        JJWriter writer = context.getBean("JJWriter", JJWriter.class);

Before executing the program, you must have also configured your Gradle/Maven dependencies.


Maven POM File

You need to add Spring Boot dependencies instead of Spring dependencies. Spring Boot provides easy to use starter pom dependencies such as spring-boot-starter, spring-boot-starter-test, spring-boot-start-web.


<project xmlns="" xmlns:xsi="" xsi:schemaLocation="">



Search the Web

Custom Search

Searches whole web. Use the search in the right sidebar to search only within!!!