Spring Boot
Eclipse IDE
Java
Web Application Development
Software Tutorial

How to run Spring Boot web application in Eclipse itself?

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

You do not need an external application server to run a normal Spring Boot web app from Eclipse. Spring Boot packages an embedded server, so the typical workflow is to import the project, make sure the build tool resolves dependencies, and run the main application class directly inside the IDE.

If that is not working, the problem is usually not how do I deploy this to Eclipse. It is more often a missing JDK, broken Maven or Gradle import, or running the wrong class.

What Eclipse Needs Before You Run

A standard Spring Boot web project needs:

  • a supported JDK installed and configured in Eclipse
  • a Maven or Gradle project imported successfully
  • a main class annotated with @SpringBootApplication
  • the web dependency on the classpath, such as spring-boot-starter-web

In a typical project, the main class looks like this:

java
1package com.example.demo;
2
3import org.springframework.boot.SpringApplication;
4import org.springframework.boot.autoconfigure.SpringBootApplication;
5
6@SpringBootApplication
7public class DemoApplication {
8    public static void main(String[] args) {
9        SpringApplication.run(DemoApplication.class, args);
10    }
11}

That main method is what Eclipse should run.

Import the Project Correctly

If you already have a project, import it as Maven or Gradle rather than as a plain Java folder.

For Maven:

  1. File -> Import
  2. Existing Maven Projects
  3. Select the project root containing pom.xml

For Gradle, use the corresponding Gradle import and wait for dependency resolution to finish before running the app.

If Eclipse shows lots of missing imports, do not try to run yet. Fix the build import first.

Run the Application From Eclipse

Once the project is imported correctly:

  1. Open the class containing main.
  2. Right-click the file.
  3. Choose Run As -> Java Application.

Eclipse starts the Spring Boot process in its console. If the app is a web app and the default configuration is unchanged, it usually starts on port 8080.

You can then open:

text
http://localhost:8080

If you are using Spring Tools, you may also see a Spring Boot App run option. That is convenient, but plain Java Application is enough for a standard Boot project.

Example Controller to Verify It Works

If you want a minimal web endpoint to confirm the app is running:

java
1package com.example.demo;
2
3import org.springframework.web.bind.annotation.GetMapping;
4import org.springframework.web.bind.annotation.RestController;
5
6@RestController
7public class HelloController {
8    @GetMapping("/")
9    public String home() {
10        return "Spring Boot is running from Eclipse";
11    }
12}

Run the application, visit http://localhost:8080, and you should see the response.

Common Configuration Issues

A few setup problems appear repeatedly.

The first is using a JRE instead of a full JDK. Spring Boot projects need a proper Java development kit configured in Eclipse and in the build path.

The second is dependency import failure. If Maven or Gradle has not finished resolving packages, Eclipse may compile partially or not at all. Run a project refresh rather than editing the classpath manually.

The third is choosing the wrong run target. Running a test class or utility class does not start the web server. You must run the @SpringBootApplication main class.

Changing the Port

If port 8080 is already in use, set another port in src/main/resources/application.properties:

properties
server.port=9090

Then rerun the application and open http://localhost:9090.

Use DevTools for Faster Iteration

For a smoother local workflow, add Spring Boot DevTools:

xml
1<dependency>
2    <groupId>org.springframework.boot</groupId>
3    <artifactId>spring-boot-devtools</artifactId>
4    <scope>runtime</scope>
5</dependency>

That can speed up restarts during local development, though it is optional.

Common Pitfalls

The most common mistake is thinking Eclipse must host the web app like an old servlet container. A normal Spring Boot app runs as a standard Java process with an embedded server.

Another frequent issue is importing the project incorrectly, then chasing missing dependency errors as if they were Spring problems.

People also forget to run the main Boot class and instead run a random Java file. If the console output does not show Spring Boot startup logs, you probably started the wrong class.

Finally, if the app starts and immediately fails, read the Eclipse console carefully. Port conflicts, missing environment variables, and invalid configuration are usually reported there directly.

Summary

  • Run a Spring Boot web app in Eclipse by importing it as Maven or Gradle and starting the @SpringBootApplication main class.
  • You do not need an external Tomcat installation for a normal Boot app.
  • Use Run As -> Java Application unless your Eclipse setup provides a specific Spring Boot run option.
  • Fix JDK and dependency-import issues before debugging Spring itself.
  • If the server starts, test it in the browser at the configured local port.

Course illustration
Course illustration

All Rights Reserved.