Categories: JavaWeb

Spring Boot Web Application with Eclipse in 5 Clicks

This article represents tips and code samples to get you started quickly with Spring web application within few clicks. Please feel free to comment/suggest if I missed mentioning one or more important points. Also, sorry for the typos.


Steps to get started with Spring Boot Web Application

  • Go to Help > Eclipse Marketplace… and search type “spring sts” in Find text field under Search tab. Install the entry with the title such as “Spring Tool Suite (STS) for Eclipse Release”.

    Download Spring STS from Eclipse Marketplace

    Once installed, you would be asked to restart the Eclipse. Go ahead and restart the eclipse.

  • Open the new Project selector window using shortcut, CTRL + N. Type “Spring Starter” and double-click the entry namely, “Spring Starter Project”. It would take you to next window such as following. Just click “Next” and move to next step.

    Spring Starter Project Creation Dialog Box

  • On next window, select the dependencies as “Web” as shown in the diagram below.

    Spring Starter Project Creation Dialog Box – Configuration

    Click Finish. This would create the project whose source code and config files/libraries structure would look following. Note the DemoApplication.java file which gets created by default.

    Spring Starter Project Source Code Structure

     

  • Right-click on the project as shown below and start the Spring Boot app.

    Spring Starter Project Run as Spring Boot App

    Once the web app starts, access the web app in browser using URL such as http://localhost:8080/

    Access Spring Boot App From Browser

     

  • Tweak the DemoApplication code a little to start working with the Web App.
    package com.example;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.ResponseBody;
    
    @Controller
    @SpringBootApplication
    public class DemoApplication {
     
     @RequestMapping("/")
     @ResponseBody
        String home() {
            return "Hello World. How are you?";
        }
     
     public static void main(String[] args) {
      SpringApplication.run(DemoApplication.class, args);
     }
    }
    

    The same code could be found on the Spring Boot homepage. Relaunch the web app and see the changes like following by access the http://localhost:8080 in the browser.

    Spring Starter Project Run as Spring Boot App – Hello World

     


Ajitesh Kumar

I have been recently working in the area of Data analytics including Data Science and Machine Learning / Deep Learning. I am also passionate about different technologies including programming languages such as Java/JEE, Javascript, Python, R, Julia, etc, and technologies such as Blockchain, mobile computing, cloud-native technologies, application security, cloud computing platforms, big data, etc. For latest updates and blogs, follow us on Twitter. I would love to connect with you on Linkedin. Check out my latest book titled as First Principles Thinking: Building winning products using first principles thinking. Check out my other blog, Revive-n-Thrive.com

View Comments

Recent Posts

Bias-Variance Trade-off in Machine Learning: Examples

Last updated: 1st May, 2024 The bias-variance trade-off is a fundamental concept in machine learning…

15 hours ago

Mean Squared Error vs Cross Entropy Loss Function

Last updated: 1st May, 2024 As a data scientist, understanding the nuances of various cost…

15 hours ago

Cross Entropy Loss Explained with Python Examples

Last updated: 1st May, 2024 In this post, you will learn the concepts related to…

15 hours ago

Logistic Regression in Machine Learning: Python Example

Last updated: 26th April, 2024 In this blog post, we will discuss the logistic regression…

6 days ago

MSE vs RMSE vs MAE vs MAPE vs R-Squared: When to Use?

Last updated: 22nd April, 2024 As data scientists, we navigate a sea of metrics to…

7 days ago

Gradient Descent in Machine Learning: Python Examples

Last updated: 22nd April, 2024 This post will teach you about the gradient descent algorithm…

1 week ago