Spring Boot Starter Example
Table of Contents
In this article, I am going to showing how to create a spring boot starter example project.
Pre-Requisites
- Java 1.8
- Spring Boot 2.2.5.RELEASE
- Eclipse IDE
Spring boot project can be created in multiple ways.
- Eclipse Maven
- STS
- start.spring.io
Here I am going to show start.spring.io using to create spring boot project.
Step 1:
Open any browser in your system and type https://start.spring.io/ in the address bar
Step 2:
Project: Maven Project
Language: Java
Spring Boot: 2.2.5
Project Metadata :
Group: com.narayanatutorial
Artifact: SpringBootStarterExample
Dependencies: nothing select because by default spring started included.
Click on Generate – Ctrl + button to generate and download the project.
Step 3:
Unzip the downloaded project in your system and then import it into eclipse as maven project.
Open Eclipse, go to File -> Import -> Maven -> Existing Maven Projects –> click on Next — > browse the unzipped folder and then click on finish.
Step 4:
The project was imported successfully and then execute the main java program.
Source Code:
SpringBootStarterExampleApplication.java
package com.narayanatutorial.SpringBootStarterExample; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class SpringBootStarterExampleApplication { public static void main(String[] args) { System.out.println("Hello World"); SpringApplication.run(SpringBootStarterExampleApplication.class, args); } }
pom.xml
<?xml version="1.0" encoding="UTF-8"?> <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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.2.5.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.narayanatutorial</groupId> <artifactId>SpringBootStarterExample</artifactId> <version>0.0.1-SNAPSHOT</version> <name>SpringBootStarterExample</name> <description>Demo project for Spring Boot</description> <packaging>jar</packaging> <properties> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <mainClass>com.narayanatutorial.SpringBootStarterExample.SpringBootStarterExampleApplication</mainClass> </configuration> </plugin> </plugins> </build> </project>
Get full source code from git.
Hello! I am Narayanaswamy founder and admin of narayanatutorial.com. I have been working in the IT industry for more than 12 years. NarayanaTutorial is my web technologies blog. My specialties are Java / J2EE, Spring, Hibernate, Struts, Webservices, PHP, Oracle, MySQL, SQLServer, Web Hosting, Website Development, and IAM(ForgeRock) Specialist
I am a self-learner and passionate about training and writing. I am always trying my best to share my knowledge through my blog.