Welcome to Chapter 8! Up until now, we’ve focused on foundational Java concepts and building standalone console applications. While these are excellent for understanding core logic, real-world applications often require robust frameworks for web interfaces, API development, and enterprise-grade features. In this chapter, we’ll take a significant leap by introducing Spring Boot, the leading framework for building production-ready, stand-alone, and enterprise-grade Java applications.

This chapter will guide you through initializing a new Spring Boot 3.3 project. This project will serve as the unified backend and, eventually, a web host for the various mini-applications we’ll develop. We’ll set up the project structure, configure essential dependencies, and create a basic “Hello World” REST endpoint to ensure everything is correctly configured. This foundational step is crucial as it lays the groundwork for integrating more complex features, robust error handling, security, and deployment practices in subsequent chapters.

By the end of this chapter, you will have a fully functional Spring Boot application capable of serving basic web requests. You’ll understand the core components of a Spring Boot project, how to run it, and how to verify its functionality. This setup is the prerequisite for transforming our simple projects into modern, scalable web applications or microservices.

Planning & Design

Our goal is to transition from simple console applications to more robust, potentially web-based or API-driven solutions. Spring Boot provides an excellent platform for this.

Project Goal and Architecture

We will create a single Spring Boot application that will eventually house the logic for our mini-projects. This will allow us to expose them as RESTful APIs, or even serve simple web UIs. For instance, the To-Do List could become a web application, and the Calculator could be a set of REST endpoints.

For now, we’ll start with a monolithic Spring Boot application. This simplifies initial setup and development. As the project evolves, we can discuss strategies for modularization or even microservices if the complexity warrants it.

File Structure

Spring Boot projects, especially when built with Maven, follow a standard, convention-over-configuration structure. We will adhere to this structure, which typically includes:

src/
├── main/
│   ├── java/
│   │   └── com/example/miniprojects/
│   │       ├── MiniProjectsApplication.java  (Main application entry point)
│   │       └── controller/                 (Package for REST controllers)
│   │           └── HelloWorldController.java
│   └── resources/
│       ├── application.properties          (Spring Boot configuration)
│       └── static/                         (Static web resources)
│       └── templates/                      (Server-side templates)
└── test/
    └── java/
        └── com/example/miniprojects/
            └── MiniProjectsApplicationTests.java
            └── controller/
                └── HelloWorldControllerTest.java
pom.xml                                     (Maven Project Object Model)

API Endpoint Design

To verify our Spring Boot setup, we’ll create a single, simple REST API endpoint:

  • Endpoint: /api/v1/hello
  • Method: GET
  • Response: A simple text string, e.g., “Hello from Spring Boot!”

This endpoint will serve as our initial test case to confirm that the web server is running and routing requests correctly.

Step-by-Step Implementation

a) Setup/Configuration: Install JDK 25, Maven, and Generate Spring Boot Project

Before we dive into coding, ensure your development environment is ready.

1. Install Java Development Kit (JDK) 25

As of December 2025, Java 25 is the latest stable release. We highly recommend using sdkman for managing Java versions, as it simplifies installation and switching between JDKs.

  • Install sdkman (if you haven’t already): Open your terminal or command prompt and run:

    curl -s "https://get.sdkman.io" | bash
    source "$HOME/.sdkman/bin/sdkman-init.sh"
    

    Follow any on-screen instructions.

  • Install JDK 25:

    sdk install java 25-open
    

    This command installs the latest OpenJDK 25. If Java 25 isn’t immediately available, you can opt for Java 24 (e.g., sdk install java 24-open), which is also a recent LTS (Long Term Support) version. For this tutorial, we will assume Java 25.

  • Verify Java installation:

    java -version
    

    You should see output indicating Java 25 (or your chosen version).

2. Install Maven (if you haven’t already):

sdkman can also manage Maven.

  • Install Maven:

    sdk install maven
    
  • Verify Maven installation:

    mvn -v
    

    You should see output indicating Maven version (e.g., Apache Maven 3.9.6 or newer).

3. Generate the Spring Boot Project using Spring Initializr

The easiest and most recommended way to start a Spring Boot project is by using the Spring Initializr web interface.

  • Open your web browser and navigate to: https://start.spring.io/

  • Configure the project settings as follows:

    • Project: Maven Project
    • Language: Java
    • Spring Boot: 3.3.0 (or the latest stable 3.3.x version)
    • Group: com.example
    • Artifact: miniprojects (This will be the name of our project folder)
    • Name: miniprojects
    • Description: Demo project for simple Java applications with Spring Boot
    • Package name: com.example.miniprojects
    • Packaging: Jar
    • Java: 25 (or 24 if you installed that version)
  • Add Dependencies: Click the “Add Dependencies…” button and search for and add the following:

    • Spring Web: Essential for building web applications and RESTful APIs.
    • Lombok: A popular library that reduces boilerplate code (e.g., getters, setters, constructors). Highly recommended for production-ready code.
    • Spring Boot DevTools: Provides development-time features like automatic restarts and LiveReload. Crucial for developer productivity.
  • Generate and Download: Click the “Generate” button. This will download a miniprojects.zip file.

  • Extract and Import: Extract the contents of the miniprojects.zip file to a directory of your choice (e.g., ~/Projects/miniprojects). Open your preferred IDE (e.g., IntelliJ IDEA, VS Code with Java extensions, Eclipse). Import the miniprojects folder as a Maven project. Your IDE will automatically detect the pom.xml and configure the project.

4. Review pom.xml

After importing, open the pom.xml file in the root of your project. It should look similar to this (versions might slightly differ):

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>3.3.0</version> <!-- Ensure this is 3.3.x -->
		<relativePath/> <!-- lookup parent from repository -->
	</parent>
	<groupId>com.example</groupId>
	<artifactId>miniprojects</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>miniprojects</name>
	<description>Demo project for simple Java applications with Spring Boot</description>
	<properties>
		<java.version>25</java.version> <!-- Ensure this matches your JDK -->
	</properties>
	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
		<dependency>
			<groupId>org.projectlombok</groupId>
			<artifactId>lombok</artifactId>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-devtools</artifactId>
			<scope>runtime</scope>
			<optional>true</optional>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<configuration>
					<excludes>
						<exclude>
							<groupId>org.projectlombok</groupId>
							<artifactId>lombok</artifactId>
						</exclude>
					</excludes>
				</configuration>
			</plugin>
		</plugins>
	</build>

</project>
  • Explanation:
    • <parent>: Defines the spring-boot-starter-parent which provides sensible defaults for Spring Boot projects, including dependency management and plugin configuration.
    • <groupId>, <artifactId>, <version>: Standard Maven coordinates for your project.
    • <properties>: Defines project properties, most notably java.version which should match your installed JDK version.
    • <dependencies>: Lists all external libraries your project needs.
      • spring-boot-starter-web: Pulls in all necessary dependencies for building web applications (Tomcat, Spring MVC, etc.).
      • lombok: A compile-time annotation processor to reduce boilerplate code.
      • spring-boot-starter-test: Provides testing utilities (JUnit, Mockito, Spring Test) for unit and integration tests.
      • spring-boot-devtools: Enables faster development cycles with features like automatic restart on code changes.
    • <build>: Configures Maven plugins. The spring-boot-maven-plugin is crucial; it packages your application into an executable JAR.

b) Core Implementation: Create a “Hello World” REST Controller

Now that our project is set up, let’s create our first piece of Spring Boot code: a simple REST controller.

1. Locate the Main Application Class

Your IDE should show src/main/java/com/example/miniprojects/MiniProjectsApplication.java. This is the entry point for your Spring Boot application.

// src/main/java/com/example/miniprojects/MiniProjectsApplication.java
package com.example.miniprojects;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class MiniProjectsApplication {

	public static void main(String[] args) {
		SpringApplication.run(MiniProjectsApplication.class, args);
	}

}
  • Explanation:
    • @SpringBootApplication: This is a convenience annotation that combines @Configuration, @EnableAutoConfiguration, and @ComponentScan. It tells Spring Boot to automatically configure itself based on the dependencies present, and to scan for components in the current package and its sub-packages.
    • SpringApplication.run(): This static method bootstraps the Spring Boot application.

2. Create the HelloWorldController

We’ll create a new package controller under com.example.miniprojects and add our controller there.

  • Create the directory: src/main/java/com/example/miniprojects/controller/
  • Create the file: src/main/java/com/example/miniprojects/controller/HelloWorldController.java
// src/main/java/com/example/miniprojects/controller/HelloWorldController.java
package com.example.miniprojects.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * REST Controller for basic "Hello World" endpoint to verify Spring Boot setup.
 * This controller demonstrates a simple GET request mapping.
 */
@RestController // Marks this class as a REST Controller, meaning it handles incoming web requests.
@RequestMapping("/api/v1") // Base path for all endpoints in this controller.
public class HelloWorldController {

    private static final Logger logger = LoggerFactory.getLogger(HelloWorldController.class);

    /**
     * Handles GET requests to /api/v1/hello.
     * Returns a simple greeting message.
     *
     * @return A string message "Hello from Spring Boot!"
     */
    @GetMapping("/hello") // Maps HTTP GET requests for /api/v1/hello to this method.
    public String hello() {
        logger.info("Received GET request for /api/v1/hello");
        // In a real application, you might fetch data from a service layer here.
        String greeting = "Hello from Spring Boot!";
        logger.debug("Responding with: {}", greeting);
        return greeting;
    }

    /**
     * Example of a simple error scenario (not production-ready error handling).
     * This method always throws a RuntimeException to demonstrate basic logging of errors.
     *
     * @throws RuntimeException Always throws a runtime exception.
     */
    @GetMapping("/error-example")
    public String errorExample() {
        logger.error("An intentional error occurred at /api/v1/error-example");
        // In a production scenario, you would use a global exception handler.
        throw new RuntimeException("Something went wrong intentionally!");
    }
}
  • Explanation:
    • @RestController: This is a specialized version of @Component and @ResponseBody. It indicates that this class is a controller whose methods return domain objects directly to the HTTP response body, typically as JSON or XML.
    • @RequestMapping("/api/v1"): This annotation maps HTTP requests to handler methods. Here, it defines a base path /api/v1 for all endpoints within this controller. This is a good practice for API versioning.
    • Logger logger = LoggerFactory.getLogger(HelloWorldController.class);: Initializes a logger instance. Spring Boot uses SLF4J (Simple Logging Facade for Java) with Logback by default, which is a robust logging solution. We use logger.info(), logger.debug(), and logger.error() for different log levels.
    • @GetMapping("/hello"): A composed annotation that acts as a shortcut for @RequestMapping(method = RequestMethod.GET). It maps HTTP GET requests to the /hello path (relative to the controller’s base path, so /api/v1/hello).
    • The hello() method simply returns a String. Spring Boot automatically converts this string into the HTTP response body.
    • The errorExample() method demonstrates how an unhandled exception would be logged. We’ll cover proper error handling in a later section.

3. Configure Logging (Optional but Recommended)

By default, Spring Boot provides console logging. For more control, we can add an application.properties file.

  • Create/Modify the file: src/main/resources/application.properties
# src/main/resources/application.properties

# Server port (default is 8080)
server.port=8080

# Logging configuration
logging.level.root=INFO
logging.level.com.example.miniprojects=DEBUG # Set specific package to DEBUG for detailed logs
logging.file.name=logs/miniprojects.log # Log to a file
logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
logging.pattern.file=%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n

# Spring Boot DevTools configuration
spring.devtools.restart.enabled=true
spring.devtools.livereload.enabled=true
  • Explanation:
    • server.port: Specifies the port on which the Spring Boot application will run. 8080 is the default.
    • logging.level.root: Sets the default logging level for all loggers (e.g., INFO, DEBUG, WARN, ERROR).
    • logging.level.com.example.miniprojects: Overrides the root level for our specific application package, allowing us to see DEBUG messages from our own code. This is very useful during development.
    • logging.file.name: Directs logs to a file named miniprojects.log within a logs directory relative to the application’s execution path.
    • logging.pattern.console and logging.pattern.file: Define the format of log messages for console and file output, respectively. This provides more structured and readable logs.
    • spring.devtools.restart.enabled: Enables automatic application restarts when files on the classpath change.
    • spring.devtools.livereload.enabled: Enables LiveReload, which can automatically refresh your browser when static resources (like HTML, CSS, JS) change.

c) Testing This Component: Manual Verification & Basic Unit Test

It’s crucial to verify our setup before moving forward.

1. Run the Spring Boot Application

There are several ways to run your application:

  • From your IDE: Locate the MiniProjectsApplication.java file, right-click, and select “Run MiniProjectsApplication.main()”.

  • From Maven: Open your terminal in the root directory of the miniprojects project and run:

    mvn spring-boot:run
    

    You should see Spring Boot’s ASCII art logo and logging messages indicating that the application has started on port 8080.

    ...
    2025-12-04T10:30:00.123  INFO 12345 --- [  main] com.example.miniprojects.MiniProjectsApplication : Starting MiniProjectsApplication using Java 25.0.0...
    ...
    2025-12-04T10:30:05.456  INFO 12345 --- [  main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
    2025-12-04T10:30:05.460  INFO 12345 --- [  main] com.example.miniprojects.MiniProjectsApplication : Started MiniProjectsApplication in 6.234 seconds (process running for 7.123)
    

2. Manual Verification via HTTP Request

Once the application is running, open your web browser or use a command-line tool like curl to access the endpoint.

  • Using a browser: Navigate to http://localhost:8080/api/v1/hello

  • Using curl in your terminal:

    curl http://localhost:8080/api/v1/hello
    

    You should receive the response:

    Hello from Spring Boot!
    

    Check your application’s console output; you should see the INFO log message: Received GET request for /api/v1/hello. If you configured logging.level.com.example.miniprojects=DEBUG, you’ll also see the DEBUG message: Responding with: Hello from Spring Boot!.

    Also, try the error example:

    curl http://localhost:8080/api/v1/error-example
    

    You’ll get a default Spring Boot error page (Whitelabel Error Page) and see the ERROR log message in your console.

3. Create a Basic Unit Test for the Controller

Spring Boot provides excellent testing support. Let’s create a simple test for our HelloWorldController.

  • Create the directory: src/test/java/com/example/miniprojects/controller/
  • Create the file: src/test/java/com/example/miniprojects/controller/HelloWorldControllerTest.java
// src/test/java/com/example/miniprojects/controller/HelloWorldControllerTest.java
package com.example.miniprojects.controller;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.test.web.servlet.MockMvc;

import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

/**
 * Unit tests for the HelloWorldController.
 * Uses @WebMvcTest to test only the web layer without starting the full Spring application context.
 */
@WebMvcTest(HelloWorldController.class) // Focuses on testing web components and mocks the rest.
public class HelloWorldControllerTest {

    @Autowired
    private MockMvc mockMvc; // MockMvc is used to simulate HTTP requests.

    /**
     * Test case to verify that the /api/v1/hello endpoint returns the correct greeting message
     * and an HTTP 200 OK status.
     *
     * @throws Exception if an error occurs during the mock MVC request.
     */
    @Test
    @DisplayName("Should return 'Hello from Spring Boot!' for GET /api/v1/hello")
    void helloEndpointReturnsGreeting() throws Exception {
        mockMvc.perform(get("/api/v1/hello")) // Perform a GET request to the specified URL.
                .andExpect(status().isOk()) // Expect the HTTP status to be 200 OK.
                .andExpect(content().string("Hello from Spring Boot!")); // Expect the response body to match the string.
    }

    /**
     * Test case to verify that the /api/v1/error-example endpoint throws an exception
     * and results in an HTTP 500 Internal Server Error status.
     *
     * @throws Exception if an error occurs during the mock MVC request.
     */
    @Test
    @DisplayName("Should return HTTP 500 for GET /api/v1/error-example")
    void errorExampleEndpointReturnsInternalServerError() throws Exception {
        mockMvc.perform(get("/api/v1/error-example")) // Perform a GET request.
                .andExpect(status().isInternalServerError()); // Expect HTTP 500.
    }
}
  • Explanation:
    • @WebMvcTest(HelloWorldController.class): This annotation is specific for testing Spring MVC controllers. It auto-configures Spring MVC infrastructure and limits the beans loaded to only those relevant to the web layer (e.g., @Controller, @RestController, @ControllerAdvice). It does not load the full application context, making tests faster.
    • @Autowired MockMvc mockMvc: MockMvc allows us to perform requests against the controller without actually starting an HTTP server. It’s excellent for fast and isolated web layer testing.
    • mockMvc.perform(get("/api/v1/hello")): Simulates an HTTP GET request to the /api/v1/hello endpoint.
    • .andExpect(status().isOk()): Asserts that the HTTP response status code is 200 OK.
    • .andExpect(content().string("Hello from Spring Boot!")): Asserts that the response body content is exactly “Hello from Spring Boot!”.
    • @DisplayName: Provides a more readable name for the test in test reports.

4. Run the Tests

  • From your IDE: Right-click on HelloWorldControllerTest.java and select “Run ‘HelloWorldControllerTest’”.
  • From Maven: Open your terminal in the root directory of the miniprojects project and run:
    mvn test
    
    You should see output indicating that the tests ran successfully and passed.

Production Considerations

While we’re just starting, it’s crucial to keep production concerns in mind from the outset.

Error Handling

Spring Boot provides a default “Whitelabel Error Page” for unhandled exceptions. This is not suitable for production, as it can expose internal details.

  • Best Practice: In a real application, you would implement a global exception handler using @ControllerAdvice and @ExceptionHandler to return structured, user-friendly error responses (e.g., JSON error objects) without exposing sensitive information. We will explore this in a future chapter.

Performance Optimization

  • AOT Compilation & GraalVM Native Images: Spring Boot 3.x is highly optimized for Ahead-Of-Time (AOT) compilation and GraalVM Native Images. This can drastically reduce startup times and memory footprint, especially crucial for microservices or serverless functions. While we won’t configure this immediately, be aware it’s a powerful option for production deployment.
  • Spring Boot DevTools: Remember that spring-boot-devtools is for development only. It should be excluded from production builds. Maven’s optional and runtime scopes help manage this.

Security Considerations

  • Default State: Out of the box, our basic Spring Boot application has no explicit security configured. This means all endpoints are publicly accessible.
  • Authentication & Authorization: For any real-world application, you would integrate Spring Security to handle authentication (who is this user?) and authorization (what can this user do?). This involves adding spring-boot-starter-security and configuring security rules. We will cover basic security in later chapters when we build more complex features.
  • HTTPS/TLS: Always deploy production applications with HTTPS enabled to encrypt communication. This is typically configured at the load balancer or web server level (e.g., Nginx, cloud load balancers) rather than directly in the Spring Boot application, though embedded Tomcat supports it.

Logging and Monitoring

  • Structured Logging: Our application.properties sets up basic file logging. For production, consider using structured logging (e.g., JSON format) that can be easily parsed by log aggregation systems like ELK Stack (Elasticsearch, Logstash, Kibana) or Splunk.
  • External Monitoring: Integrate with monitoring tools (e.g., Prometheus, Grafana, Datadog, New Relic) to track application health, performance metrics, and error rates. Spring Boot Actuator provides production-ready endpoints for monitoring and managing your application.

Code Review Checkpoint

At this point, you should have a clean, runnable Spring Boot project.

Summary of what was built:

  • A new Maven-based Spring Boot 3.3 project.
  • pom.xml configured with spring-boot-starter-web, lombok, spring-boot-devtools, and spring-boot-starter-test.
  • A HelloWorldController with a /api/v1/hello GET endpoint and a simple error example.
  • Basic logging configuration in application.properties.
  • A unit test for the HelloWorldController using MockMvc.

Files created/modified:

  • pom.xml (generated by Initializr, reviewed)
  • src/main/java/com/example/miniprojects/MiniProjectsApplication.java (generated, reviewed)
  • src/main/java/com/example/miniprojects/controller/HelloWorldController.java (NEW)
  • src/main/resources/application.properties (NEW)
  • src/test/java/com/example/miniprojects/controller/HelloWorldControllerTest.java (NEW)

How it integrates with existing code: This Spring Boot project is a new, separate foundation. It doesn’t directly integrate with the console applications built in previous chapters. Instead, it provides the platform upon which we will rebuild and enhance those applications as web-based services or UIs. Think of it as a new, more powerful chassis for our existing engine logic.

Common Issues & Solutions

  1. Port 8080 already in use:

    • Error: Address already in use: bind or Port 8080 was already in use.
    • Cause: Another application (e.g., another Spring Boot app, a web server) is already using port 8080.
    • Solution:
      • Identify and stop the process using port 8080.
        • On Linux/macOS: sudo lsof -i :8080 then kill -9 <PID>
        • On Windows: netstat -ano | findstr :8080 then taskkill /PID <PID> /F
      • Alternatively, change the server.port in src/main/resources/application.properties to another available port (e.g., server.port=8081).
  2. Whitelabel Error Page for valid endpoints:

    • Error: You navigate to http://localhost:8080/api/v1/hello but see Spring Boot’s “Whitelabel Error Page”.
    • Cause: This usually means your controller mapping is incorrect, or the controller class isn’t being scanned by Spring.
    • Solution:
      • Double-check the @RequestMapping and @GetMapping annotations in HelloWorldController.java. Ensure they match /api/v1/hello.
      • Verify that HelloWorldController.java is within the com.example.miniprojects package or a sub-package. @SpringBootApplication’s @ComponentScan scans the package where MiniProjectsApplication.java resides and its sub-packages.
      • Ensure the application started without errors. Check the console logs for any WARN or ERROR messages during startup.
  3. Missing Dependencies / Build Errors:

    • Error: java.lang.ClassNotFoundException or Maven build failures related to missing symbols.
    • Cause: Maven dependencies were not properly downloaded or resolved, or your IDE’s Maven configuration is out of sync.
    • Solution:
      • In your IDE, refresh/reimport the Maven project.
      • From the terminal, run mvn clean install to clean the project and download all dependencies.
      • Ensure your internet connection is stable, as Maven downloads dependencies from remote repositories.

Testing & Verification

To confirm everything is correctly set up for this chapter:

  1. Run the application: Execute mvn spring-boot:run in your project’s root directory.
  2. Verify the “Hello World” endpoint:
    • Open http://localhost:8080/api/v1/hello in your browser. You should see “Hello from Spring Boot!”.
    • Check the console for INFO and DEBUG logs related to the request.
  3. Verify the error endpoint:
    • Open http://localhost:8080/api/v1/error-example in your browser. You should see the Spring Boot Whitelabel Error Page (or a similar error response).
    • Check the console for an ERROR log message from your HelloWorldController.
  4. Run all tests: Execute mvn test in your project’s root directory. All tests, including HelloWorldControllerTest, should pass successfully.
  5. Check log file: Verify that a logs/miniprojects.log file has been created in your project root (or wherever you configured it) and contains the log messages from your application runs.

If all these steps are successful, congratulations! Your Spring Boot 3.3 project is correctly initialized and ready for development.

Summary & Next Steps

In this chapter, we successfully laid the foundation for our advanced Java projects by initializing a Spring Boot 3.3 application. We installed the necessary JDK 25 and Maven, generated the project using Spring Initializr, configured essential dependencies, and created a basic RESTful “Hello World” endpoint. We also discussed crucial production considerations like error handling, performance, security, and logging.

This new Spring Boot project will serve as the backend for our mini-applications, allowing us to evolve them into robust, web-accessible services. This is a significant step towards building production-ready applications.

In the next chapter, we will leverage this Spring Boot foundation to build the Simple Calculator as a RESTful API. We’ll implement addition, subtraction, multiplication, and division operations, focusing on robust input validation, proper error handling, and unit testing within the Spring Boot ecosystem.