Create Spring Boot application using Eclipse

In this article lets learn how to create spring boot application using Eclipse

You have three ways to bootstrap your spring boot application

  1. Using spring Initalizr at https://start.spring.io
  2. Using Sprint Tool Suite (STS) to create spring boot application
  3. Using Eclipse with Spring plugin

Using spring Initlializr at https://start.spring.io

Spring initializr is a great tool for creating a boiler plate spring boot application by following these simple steps

https:/start.spring.io
  • Choose project type Maven or Gradle. For our demo, I chose maven
  • Choose Language (Java/Kotlin/Groovy)
  • Spring boot version (Milestone/snapshot or stable)
  • Input project metadata Group, Artifact
  • Add any dependencies you need for the project (web, jpa, security etc.). I chose web for this demo
  • Click on generate project
  • We should be able to download and extract spring boot project

Upon downloading zip file from start.spring.io website, open your eclipse IDE and select File -> Import -> Existing Maven Projects as show in below screenshot.

Select extracted demo project into eclipse by clicking “Next” as shown in below screenshot

Click finish to complete importing project into eclipse.

Using Spring Tool Suite (STS)

Create new project in STS using File -> New -> Spring Starter Project menu

In above screen I have kept all default but feel free to update details as needed and click “Next” button

Select “web” from the dependencies list and click next and finish. Now you should see spring initializing spring boot project in your STS IDE. You project should look as show in below screen

You can select demo and start server using Spring Dashboard. Check running the project as discussed later in this article.

Using Eclipse With Spring Plugin

Open Eclipse IDE and install spring plugin in case if you haven’t installed before this by following below steps

Installing Spring plugin

  • Go to Help -> Eclipse Marketplace
  • Search for Spring and install the plugin
  • After installing plugin, restart your eclipse IDE

After installing or ensuring that spring plugin is available in your eclipse, now start creating project using File -> New -> Project -> Spring Boot -> Spring Starter Project. Rest of the steps are same as we discussed in Using Spring Tool Suite (STS) section.

Running Demo Project

After successful import of demo project into eclipse, you should be able to see complete project structure with an application main class as shown below

Now run the DemoApplication class and you should able to see the logs in console indicating that tomcat server is up and running

For demo purposes, I have added a static index.html file under demo/src/main/resources/static

Open your browser and goto http://localhost:8080 and you should be able to see your first spring boot application in action as below