Project Structure
Let’s take a fresh look at this project.
If you’re unfamiliar with Maven, it’s worth pointing out that most of this project structure is defined by Maven and not Spring Boot.
We have a Maven pom.xml file in the root of our project – we’ll look at its contents in a moment.
You’ll also notice other files with mvn in name, mvnw, mvnw.cmd and the .mvn directory.
Together, this is a bundled instance of maven that we can use to build our project. If we open up a terminal on a *nix and type:
mvnw installOr on windows:
./mvnw installWe’ll be using this "maven wrapper" to build your project.
If we look in our pom.xml file, we can see a parent node for spring-boot-starter-parent with version 3.3.5 – the version of Spring Boot we selected in the Initialzr.
Next we see the project metadata we set in the project.
We see Java 21 – the Java version we specified in the Initialzr.
Finally we see the dependencies we selected, including spring-boot-starter-data-jpa, spring-boot-starter-data-web, h2, postgresql and then the spring-boot-starter-test.
As we’ll only be using H2 to provide a database in any tests – completing the application context, I’m going to change the scope of this dependency from runtime to test.
Digging further into the application we have the src/main/java and src/main/resources – this structure is typical of a Maven project.
In the Java directory we have packages which represent those we specified in the Initialzr and a single TaskApplication class.
If we look in the resources directory we see application.properties which we can use to configure our Spring Boot application – at the moment it just contains a single property which specifies the name of the application.
Inside of TasksApplication we have a main method – the entrypoint of our application and we can see the class is annotated with @SpringBootApplication – marking this as a Spring Boot application and doing all the necessary work to make it that way.
Clicking the green triangle next to the main class or method will run the application – which we can see fails to start as it cannot connect to a PostgreSQL database.
Summary
- Maven-based project structure with wrapper (
mvnw) andpom.xmlconfiguration - Key dependencies: Spring Boot 3.3.5, JPA, Web, PostgreSQL, H2 (test)
- Standard Maven directories with Spring Boot application class
- Application currently fails due to missing database connection