Spring Framework Tutorial

Software Setup and Configuration (STS/Eclipse/IntelliJ)

Core Spring

Spring Annotations

Spring Data

Spring JDBC

Spring Security

How to Create and Setup Spring Boot Project in Eclipse IDE?

Creating and setting up a Spring Boot project in Eclipse (or the Spring Tool Suite, an Eclipse-based IDE designed for Spring development) is straightforward. Here's a step-by-step guide:

1. Install the Spring Tools Plugin (if not using Spring Tool Suite):

If you're using plain Eclipse IDE and not the Spring Tool Suite (STS), you can install the Spring Tools plugin to get Spring Boot project templates:

  • Go to Help > Eclipse Marketplace.
  • Search for Spring Tools.
  • Click Install for the Spring Tools 4 (or the latest version available).
  • Restart Eclipse after installation.

2. Create a New Spring Starter Project:

  • Go to File > New > Spring Starter Project. If you don't see this option, you might need to choose File > New > Other... and then find Spring > Spring Starter Project.

  • In the New Spring Starter Project dialog, fill in the details:

    • Name: The name of your project.
    • Type: Choose the build tool (Maven or Gradle). Maven is more commonly used.
    • Packaging: JAR (recommended for Spring Boot) or WAR.
    • Java Version: Choose the Java version you want to use.
    • Language: Java, Kotlin, or Groovy. Java is the most commonly used.
    • Group: Base package for your project, usually in the format of com.example.
    • Artifact: A unique ID for your project.
    • Version: Project version.
    • Description: A brief description of your project.
    • Package: The package structure for your main application. By default, it's derived from the Group and Artifact values.
  • Click Next.

3. Choose Dependencies:

In the next dialog, you can search and select Spring Boot Starter dependencies that you want to add to your project:

  • For a basic web application, you might choose Spring Web Starter.

  • If you plan to use a database, you might select Spring Data JPA and a database connection pool like HikariCP.

  • For testing, you could select Spring Boot Starter Test.

  • Once you've chosen your dependencies, click Next.

4. Review and Finish:

  • Review the details.
  • Click Finish.

5. Maven/Gradle Build:

If you chose Maven or Gradle, Eclipse would automatically start the initial build process, pulling in the necessary dependencies from the Maven Central Repository or the specified repositories for Gradle.

6. Project Structure:

Your project will be created with a standard Spring Boot structure. In the src/main/java directory, you'll find a main application class with the @SpringBootApplication annotation. This class is the entry point for your Spring Boot application.

7. Running the Application:

  • Right-click on the main application class or any other class with a public static void main(String[] args) method.
  • Choose Run As > Java Application.

If you've added the Spring Web Starter dependency, you can now access your application at http://localhost:8080.

That's it! You've successfully set up a Spring Boot project in Eclipse. Adjust configurations, add code, and expand your application as needed.