Thursday, October 5, 2017

Getting started with spring boot , eclipse and maven

This post will explain about How to work with spring boot , eclipse and maven

Step 1: Start eclipse
Step 2: Create new java project
Step 3 : Add below code into pom.xml file







Step 4: Right click on Project-> Configure->Convert To Maven Project
Step 5: If maven plugin not installed in your eclipse then got to market place of eclipse and search for maven , install from there.
Step 6: Now we need to create source folder -
create a folder with name main under src folder
create a folder with name java under main folder
create a folder with name test under main folder

Step 7: Link created folder to src.
Right click on src -> new -> Source folder -> browse on Folder Name-> Give upto main/java
Check the first check box

Right click on src -> new -> Source folder -> browse on Folder Name-> Give upto main/test
Check the first check box

Step 8: Create package wiht name springboot and create a class called

     package springboot;

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

public class HelloController {
    public String index() {
        return "Greetings from Spring Boot you have done the greate job!";


Step 9: Create a class called Application . This is the main class to run the spring boot application.

    package springboot;

import java.util.Arrays;

import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;

public class Application {

    public static void main(String[] args) {, args);

    public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
        return args -> {

            System.out.println("Spring boot beans:");

            String[] beanNames = ctx.getBeanDefinitionNames();
            for (String beanName : beanNames) {




Step 10:Now we need to run this project. Right click on the pom.xml file and Run As -> maven install
Step 11: After Build success . Now we Need to run the Spring Boot Applcation.
Step 12 : Right click on the Run As - Java Application.
Step 13 : Once executed successfully, then open any Browser and type - http://localhost:8080/
Step 14: Out put will be -Greetings from Spring Boot you have done the greate job! - This details will be available in
Step 15: If you notice that , spring boot will have in built tomcat. Once we started Spring boot, then it will start the tomcat. No external server configuration required.
Step 16 : if you want to know more about spring boot please check the Spring Boot
Step 17 : if you want to change the out put in HelloController. change the return value and again try to run the
In this case you may get the below error
      2017-10-05 11:23:38.382  INFO 9172 --- [           main]  : Starting beans in phase 0
2017-10-05 11:23:41.318 ERROR 9172 --- [           main] o.a.coyote.http11.Http11NioProtocol      : Failed to start end point associated with ProtocolHandler ["http-nio-8080"] Address already in use: bind
 at Method) ~[na:1.8.0_131]
 at Source) ~[na:1.8.0_131]
 at Source) ~[na:1.8.0_131]
        service.getName(): "Tomcat";  Protocol handler start failed
 at org.apache.catalina.connector.Connector.startInternal( ~[tomcat-embed-core-8.5.20.jar:8.5.20]
 at org.apache.catalina.util.LifecycleBase.start( ~[tomcat-embed-core-8.5.20.jar:8.5.20]
 ... 13 common frames omitted
Caused by: Address already in use: bind
The Tomcat connector configured to listen on port 8080 failed to start. The port may already be in use or the connector may be misconfigured.


To Kill the existing port 8080, which is already in use.
Step 18: Go to command prompt- type netstat -a -o -n
Step 19 find the PID for tomcat port then kill that PID using below command
Step 20 - taskkill /F /PID 28345

Thanks for viewing this post.

Contact Form


Email *

Message *