Spring Boot Example Tutorials | Spring Boot Hello World Example Online TutorialsPoint

PROGRAMMINGJava ExamplesC Examples
Java Examples
C Examples
C Tutorials
aws
JAVAEXCEPTIONSCOLLECTIONSSWINGJDBC
EXCEPTIONS
COLLECTIONS
SWING
JDBC
JAVA 8
SPRING
SPRING BOOT
HIBERNATE
PYTHON
PHP
JQUERY
PROGRAMMINGJava ExamplesC Examples
Java Examples
C Examples
C Tutorials
aws
In this tutorial, I am going to show you the most popular and trending module in Spring Framework that is Spring Boot. By this tutorials you can get to know how to write a Simple Spring Boot Example.
Used Technologies :
Spring 3.2.3
Spring Boot 1.5.1
Java 8
Maven 3
Here I am going to implement a basic hello world spring boot example.
Project Structure :
Maven Dependencies :
To make our example as simple as possible, I have placed dependencies in pom.xml what just I want.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.samples</groupId>
<artifactId>Spring_Boot_Example</artifactId>
<version>0.0.1-SNAPSHOT</version>

<properties>

<!-- Generic properties -->
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<!-- Spring -->
<spring-framework.version>3.2.3.RELEASE</spring-framework.version>

</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.1.RELEASE</version>
</parent>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

Create Application Class :
package com.onlinetutorialspoint.spring.boot;

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

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

@SpringBootApplication annotation tells the spring application context, it is an spring boot application. Most of the developers can used to define the spring boot main classes with the @Configuration, @EnableAutoConfiguration and @ComponentScan annotations. Since these annotations are mandatory to every Spring application, the Spring Boot given us an annotation called @SpringBootApplication instead.
Here @Configuration + @EnableAutoConfiguration + @ComponentScan = @SpringBootApplication
package com.onlinetutorialspoint.spring.boot;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {
    @RequestMapping("/")
    public String index() {
        return "Hello World Spring !";
    }
}

Running the Spring Boot Example :
On e of the biggest advantage of Spring boot application is, to run we don’t deploy the application in any server. We can run the above spring boot example as a simple Java standalone application.
Run the main method in Application.java.
If every thing goes well, you can find the below text in your console.

Run it :
Happy Learning 🙂


spring_boot_example

Simple Spring Boot Example
File size: 9 KB
Downloads: 1204


Spring Boot Environment Properties reading based on activeprofile
Spring Boot FileUpload Ajax Example
SSL Spring Boot HTTPs Enabling Example
Spring Boot Validation Login Form Example
External Apache ActiveMQ Spring Boot Example
Spring Boot In Memory Basic Authentication Security
Step By Step Spring Boot Docker Deployment Example
Spring Boot Hibernate Integration Example
Spring Boot JPA Integration Example
Spring boot exception handling rest service (CRUD) operations
Spring Boot MongoDB + Spring Data Example
Spring Boot MVC Example Tutorials
Spring Boot How to change the Tomcat to Jetty Server
How to Send Mail Spring Boot Example
How to set Spring boot favicon image

Spring Boot Environment Properties reading based on activeprofile
Spring Boot FileUpload Ajax Example
SSL Spring Boot HTTPs Enabling Example
Spring Boot Validation Login Form Example
External Apache ActiveMQ Spring Boot Example
Spring Boot In Memory Basic Authentication Security
Step By Step Spring Boot Docker Deployment Example
Spring Boot Hibernate Integration Example
Spring Boot JPA Integration Example
Spring boot exception handling rest service (CRUD) operations
Spring Boot MongoDB + Spring Data Example
Spring Boot MVC Example Tutorials
Spring Boot How to change the Tomcat to Jetty Server
How to Send Mail Spring Boot Example
How to set Spring boot favicon image






Spring Boot Training
March 2, 2018 at 9:36 am - Reply 

Looking nice information about Spring Boot
Plz do keep sharing on









bhanu pratap
July 24, 2018 at 2:57 pm - Reply 

Good Article,valuable information, Best software Training institute in Bangalore 









vinod kumar mvn
August 31, 2018 at 2:45 pm - Reply 

The Article is very Informative and Worth Reading For the Candidates like me. Currently, I am learning spring boot training and this Article is helpful for me to understand the things very easily.
Thanks









Katherine
December 27, 2018 at 10:50 am - Reply 

Hello ChandraSekhar,
I really Appreciate your work, here you given a very informative post. As a beginner to SpingBoot technology, I found some new points, which is very much usefull for me. And thiss very much helpfull for every beginner.










Spring Boot Training
March 2, 2018 at 9:36 am - Reply 

Looking nice information about Spring Boot
Plz do keep sharing on




Looking nice information about Spring Boot
Plz do keep sharing on





bhanu pratap
July 24, 2018 at 2:57 pm - Reply 

Good Article,valuable information, Best software Training institute in Bangalore 




Good Article,valuable information, Best software Training institute in Bangalore 





vinod kumar mvn
August 31, 2018 at 2:45 pm - Reply 

The Article is very Informative and Worth Reading For the Candidates like me. Currently, I am learning spring boot training and this Article is helpful for me to understand the things very easily.
Thanks




The Article is very Informative and Worth Reading For the Candidates like me. Currently, I am learning spring boot training and this Article is helpful for me to understand the things very easily.
Thanks





Katherine
December 27, 2018 at 10:50 am - Reply 

Hello ChandraSekhar,
I really Appreciate your work, here you given a very informative post. As a beginner to SpingBoot technology, I found some new points, which is very much usefull for me. And thiss very much helpfull for every beginner.




Hello ChandraSekhar,
I really Appreciate your work, here you given a very informative post. As a beginner to SpingBoot technology, I found some new points, which is very much usefull for me. And thiss very much helpfull for every beginner.
 


Δ
 Spring Boot – Hello World
 Spring Boot – MVC Example
 Spring Boot- Change Context Path
 Spring Boot – Change Tomcat Port Number
 Spring Boot – Change Tomcat to Jetty Server
 Spring Boot – Tomcat session timeout
 Spring Boot – Enable Random Port
 Spring Boot – Properties File
 Spring Boot – Beans Lazy Loading
 Spring Boot – Set Favicon image
 Spring Boot – Set Custom Banner
 Spring Boot – Set Application TimeZone
 Spring Boot – Send Mail
 Spring Boot – FileUpload Ajax
 Spring Boot – Actuator
 Spring Boot – Actuator Database Health Check
 Spring Boot – Swagger
 Spring Boot – Enable CORS
 Spring Boot – External Apache ActiveMQ Setup
 Spring Boot – Inmemory Apache ActiveMq
 Spring Boot – Scheduler Job
 Spring Boot – Exception Handling
 Spring Boot – Hibernate CRUD
 Spring Boot – JPA Integration CRUD
 Spring Boot – JPA DataRest CRUD
 Spring Boot – JdbcTemplate CRUD
 Spring Boot – Multiple Data Sources Config
 Spring Boot – JNDI Configuration
 Spring Boot – H2 Database CRUD
 Spring Boot – MongoDB CRUD
 Spring Boot – Redis Data CRUD
 Spring Boot – MVC Login Form Validation
 Spring Boot – Custom Error Pages
 Spring Boot – iText PDF
 Spring Boot – Enable SSL (HTTPs)
 Spring Boot – Basic Authentication
 Spring Boot – In Memory Basic Authentication
 Spring Boot – Security MySQL Database Integration
 Spring Boot – Redis Cache – Redis Server
 Spring Boot – Hazelcast Cache
 Spring Boot – EhCache
 Spring Boot – Kafka Producer
 Spring Boot – Kafka Consumer
 Spring Boot – Kafka JSON Message to Kafka Topic
 Spring Boot – RabbitMQ Publisher
 Spring Boot – RabbitMQ Consumer
 Spring Boot – SOAP Consumer
 Spring Boot – Soap WebServices
 Spring Boot – Batch Csv to Database
 Spring Boot – Eureka Server
 Spring Boot – MockMvc JUnit
 Spring Boot – Docker Deployment