DEV Community

KIRAN RAJ
KIRAN RAJ

Posted on

Maven & MVC in Spring Boot

Maven & MVC in Spring Boot — how I actually understood it

When I started Spring Boot, I kept hearing two words again and again -Maven and MVC.

  • At that time I didn’t really get it.
  • Still, I didn’t ask… just went with the flow thinking it’ll make sense later.
  • This is basically what I undeThat’s pretty much it.understood after struggling a bit.

Maven first.

  • When you create a Java project, you don’t just write code and run it.
  • You need other stuff — Spring Boot, database drivers, some libraries.
  • Initially I thought I could handle it manually. Download jars, add them, done.

  • It works, but only for some time.

  • After that, small problems start:

  • wrong versions, something not working, no idea what went wrong.

  • That’s where Maven helps.

  • You just write everything in one file (pom.xml).

  • After that, it takes care of the rest — downloading, managing versions, building.

  • You don’t really “see” Maven working.

  • It just does things in the background.

  • After a point, you stop thinking about it completely.


Now MVC.

  • Before this, I used to write everything in one place.
  • Controller, logic, data… all mixed.
  • It was okay for small code, but once it got bigger, it became confusing.
  • MVC just separates things. That’s it.

Controller — where the request comes.

  • If you hit something like /users, it reaches the controller first.
  • Controller won’t do everything.
  • It just decides what should happen next and passes it.

Model — your data.

  • Like a User: id, name.
  • Nothing complicated.
  • Just represents what you’re working with.

View — what goes back.

  • In most cases, it’s just JSON.
  • User asks → you send data → done.

What made it clear for me was this:

  • request → controller → process → response
  • That’s the whole flow.
  • I was overthinking it before.

One simple way I remember it:

like ordering food.

  • You talk to waiter → controller
  • Waiter goes inside → model
  • Food comes back → view You never go to the kitchen.
  • Same thing here.

*One mistake I made — I thought Maven and MVC are related.
*

They’re not.

  • MVC is about how you write code.
  • Maven is just there handling dependencies and setup.

That’s pretty much it.

  • Honestly, reading won’t make it fully click.
  • Try a small API, return some data… then it makes sense.

Top comments (0)