Spring Boot: Nice and Easy [Video]
Want a fun and engaging intro to the whole Spring Boot ecosystem? Check out this live-coding session on a new episode of "Marco Codes."
Join the DZone community and get the full member experience.
Join For FreeEver looked for a comprehensive intro to Spring Boot that is fun and entertaining at the same time? Then have a look at this brand-new episode of the "Marco Codes" YouTube channel: Spring Boot - Nice & Easy.
In this video, we will build a tiny Google Photos-like clone with Spring Boot. Additionally, along the way, you'll learn plenty about Spring's Dependency Injection and MVC frameworks, Validation and File Handling, Spring Data and Databases, and you'll even deploy your application at the end.
What’s in the Video?
Every new Spring Boot project starts with the question: How do I create my new project (hint: Spring Initializr) and what do I need to watch out for when setting up my project? Hence, we'll start off with that.
While the end goal of the video is to program a tiny Google Photos-like clone, we'll first continue with a quick win, Writing a Hello World @RestController
, teaching you the very basics of Spring Boot such as project structure, classes, and beginner concepts.
Next, we'll be off to some real-life REST API Design. We want to store and retrieve photos, so we'll need to model our domain as Java classes. After modeling the domain, it's time to think about what our REST API would look like, what classes we need, and how to structure them and our project. That means we will get familiar with Spring Boot's mapping annotations, including @GetMapping
, @PostMapping
, or @DeleteMapping
, and start sending very simple String messages via HTTP.
Building stuff on the backend is, however, just one part of the coin. We'll also need a way to test our REST endpoints. A very simple way of doing that is by executing JavaScript inside your browser's developer console. We'll do that first, instead of resorting back to a full-blown HTTP client.
At some point, sending strings only takes you so far. We'll need to change our Spring Boot backend so it can handle JSON messages as well as validate those JSON messages so users cannot send invalid or even dangerous contents to make our server crash. Validation also means displaying error messages and we'll find out how you can handle those with Spring Boot.
With that many learnings under our belt, we'll dig into Spring Boots basics (i.e., dependency injection) in much more detail and talk about the pros and cons of different injection styles.
What would a real-life application be without database access? Let's change our application so that it stops saving photos on a hard disk, but instead saves them to a database. That way, you'll learn about Spring Data (JDBC) and the various ways you can access databases with Spring Boot.
Last but not least, you'll also want to be able to deploy your application. Building final deployables with Spring Boot is rather simple and you'll learn how to run your Spring Boot application on any production server you like.
If you managed to watch the entire video, you'll be presented with some hints, tips, and resources, that will help you continue your Spring Boot learning journey on your own. Check it out and let us know what you think!
Opinions expressed by DZone contributors are their own.
Comments