This is my first post. I just wanted to write something and start. So it is here.
I am a theory person. I like learning the mental theory or use case theory about any development concepts. I don't usually code unless I understand theory perfectly.
Which I think is very big drawback. So even though I know some theory about spring boot I never made apps using it.
So today my goal was to initialize simple spring app and remember next time how to do the same.
So this might feel dumb, but this is how I remember it:
Spring Intializer
1.First, you go to spring initializer (https://start.spring.io/), add project name, domain name, choose dependency management tool-Maven, Java version 21, configuration- properties and most important - add dependencies like Spring web, Spring Data JPA etc. Download the jar file and open it in either IntelliJ IDE or STS (Spring tool suite).
Project Structure
2.After that you get simple spring app project structure with dependencies you added while creating project jar file. You get the application. properties file which contains nothing but project name. You get pom.xml file in which project related dependencies are mentioned there with version and what not. When you use spring initializer it fetches the correct names of these dependencies and their matching versions.

3.Structure is simple as well, 'src/main/java' -> 'com/example/pk/project_name' (for ex com/ex/pk/TaskManager and then coding part- ProjectNameApplication (for ex, TaskManagerApplication) java class with spring boot annotation @SpringBootApplication above it.
@SpringBootApplication
4.@SpringBootApplication annotation is combination of three other annotations: -
- @Configuration means this class contains bean definitions, methods that returns bean object
- @EnableAutoConfiguration this annotation tells Spring boot to check the dependencies downloaded and configure things according to it. Like if web dependencies are downloaded configure the tomcat server, configure database etc.
- @ComponentScan - scan the packages and subpackages in which this class is and register the components you find into spring context. Means it'll check for components annotated with @Controller/@RestController, @Service, @Repositories etc., creates their bean and adds it into Spring context. (Context is like a box inside which beans lives and spring manages them) 4.Run the app, nothing happens mostly. If you added web dependency, go check on localhost:8080 port which is where configured tomcat server is running. You will see the white page with some error page means your app is running.
Inclusion
I know this is very basic stuff, and I've not explained everything perfectly but I'm not focusing on theory, learn by doing and escape the tutorial hell which keeps throwing me back to basics.
But I just wanted to write my first blog. I'll try to be consistent with it. I'm very lazy person with lot of distractions and I'll try to change through this.
Also, I'm not good writer either, but I saw other people's (especially senior Dev's) old blog on their personal websites like Julia Evans (https://jvns.ca/) or Jeff Atwood(https://blog.codinghorror.com/) and thought it's so cool. Their dedication, their love, their exploration, their journey and learning everything else was really cool. So I wanted to start too.
You should share your experience too. Let me know how you escaped tutorial hell in comments below!

Top comments (0)