Labs ICT
Pro Login

Setting Up Spring Boot

Creating your first Spring Boot project.

Setting Up Spring Boot

Ready to get your hands dirty? Setting up Spring Boot is surprisingly easy. It's like ordering pizza - you pick what you want, and it gets delivered ready to eat. No complicated assembly required.

The best part? You don't need to be a DevOps expert or understand complex build tools. Spring Boot makes the setup process almost enjoyable. Almost.

Using Spring Initializr

Spring Initializr is your best friend when starting a new project. It's like a menu at a restaurant - you pick what you want, and the chef prepares everything for you. Just go to start.spring.io and select your options.

You can choose your project type (Maven or Gradle), Java version, and dependencies. It's like building a custom burger - but instead of lettuce and tomatoes, you're picking web support, databases, and security features.

The interface is super intuitive. You don't need to read a manual to figure it out. It's designed for developers, by developers.

Project Dependencies

Dependencies are like ingredients in a recipe. You need the right ones to make your application work. Spring Boot provides starter dependencies that bundle everything you need together.

Here's what your pom.xml might look like with some common dependencies:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <scope>runtime</scope>
    </dependency>
</dependencies>

Notice how clean that is? No need to worry about version compatibility or transitive dependencies. Spring Boot handles all that for you.

Try it Yourself →

Maven vs Gradle

You have two choices for build tools: Maven or Gradle. It's like choosing between a manual and automatic car - both will get you there, but the experience is different.

Maven uses XML configuration and has been around longer. It's like a trusty old pickup truck - reliable and well-understood. Gradle uses Groovy or Kotlin and is more modern. It's like a sleek electric car - faster and more efficient.

My advice? Start with Maven if you're new. It's easier to understand. Once you're comfortable, try Gradle and see if you like it better.

Running Your First App

The moment of truth! Once you've created your project, running it is as simple as:

mvn spring-boot:run

Or if you're using Gradle:

gradle bootRun

That's it! Your application will start up, and you'll see some magic happening in the console. It's like watching your first plant grow - exciting and a little bit magical.

Open your browser and go to http://localhost:8080. You should see a "Whitelabel Error Page" - don't worry, that's actually good! It means your application is running. You've successfully built and run your first Spring Boot application!