Hi, if you end up here by some reason keep in my that this is my first blog post ever and also that I suck at writing, for real.
So what's Spring Boot anyways? I don't know for sure to be honest either, so I'm just gonna research for a bit and will be back in a jiff. So, it turns out that Spring Boot is something called a micro framework, and it's built on top of something called Spring (that's also a framework) used to help build Spring Applications.
So, enough with introductions, how do I go about building stuff with it?
Hello World
So, first go to src > main > java > maindomainfolder > mainApplication.java
You should see something along these lines:
When we run this code you're going to open a new localhost Apache Server (Apache is one of the Spring Framework applications, just like Spring Boot) you'll be most likely be using either port 8080 or 8888. So just go to your browser and type localhost:8080 on the address bar and you'll be greeted with this:
That's good, that means that everything is running a-ok. So, about that Hello World stuff, to do this we need first to create a Controller Class, and well, what is a controller? I'm not sure, but it's something that makes stuff work – So I just looked up what controllers are: they're a Java Class responsible for handling REST API requests, they must contain the following annotation: @RestController
– so we first create a controller and inside that controller we must map a URI to a function, and that function will be the output for that URI. So, we'll have something like this:
As you can see we have this thing called a controller and inside the controller we're mapping a URI to an output, in that case the URI is "/test/", so, when we access localhost:8080/test/
we'll be greeted with this lovely page:
And there we have it, that's our hello world
. I guess this will be it for today, hopefully this journal we'll become a bi-weekly habit, I feel like I retain much more information if I start typing it out.
Top comments (0)