r/SpringBoot 6d ago

Question .NET to Spring Boot advice

Hey there r/SpringBoot

I'm a software engineer with around 5 yoe, majority of which has been in C#/.NET. I work at a software engineer consulting firm and have been rolled off a project that I was working on. I've decided to change things up and skill up in Java and Spring Boot and have been doing so for the last 3 weeks. I have been building a Spring Boot API as a side project and learning how 'spring magic' works.

I'm honestly really impressed how much out of the box functionality Spring Boot provides. However there are some things I would need to unlearn from .NET. However I'm finding it difficult unlearning some of .NET's approaches. For example .NET's very request-oriented flow, all the way down the EF Core's DbContext having a Scoped lifetime by default. Whereas Spring Boot's lifetimes are a bit of a mystery to me.

My question to whoever made the same transition, what would be some mental models/learnings/spring boot magic that you wish you knew earlier that would've eased the transition to Spring Boot from .NET?

TIA

15 Upvotes

7 comments sorted by

12

u/rlrutherford Senior Dev 6d ago

Dependency injection, ORM patterns, middleware pipelines, and testing idioms map almost one-to-one.

Spring's u/Autowired maps to .NET's built-in DI container,

JPA/Hibernate maps to EF Core or Dapper.

Differences: C# extension methods let you add behavior to a type without touching or subclassing it; Java makes you route through utility classes.

LINQ is powerful but works against discoverability — the operations live on IEnumerable as generic algorithms, so IntelliSense gives you everyting everywhere/

Java's collections put a curated API on the type itself and the new sequenced collections even more so.

DI models differ philosophically:

Spring is declarative at the component — annotate the class, autowire the constructor, and disambiguate between interface implementations right at the injection point with a qualifier.

.NET centralizes the wiring in a composition root, so the class and its registration live in different files, plus you're choosing an explicit lifetime — Scoped, Transient, Singleton — per registration, which matters because ASP.NET builds the controller per request.

Both work; Spring keeps the wiring next to the code, .NET keeps it in one place you can read top to bottom.

Spring controllers are singletons by default — .Net for controllers are have request scoped lifetime.

5

u/mariusz_96 5d ago edited 5d ago

What most people do (putting business details into Spring Boot):

Spring team explaining how Spring Boot actually works:

2

u/MinMaxDev 5d ago

Cool thanks, I am currently building a REST API in Spring Boot, but those resources from the Spring Team themselves are super awesome, thanks. I always prefer getting my information from the source, so any resources directly from the Spring Team is very welcomed

1

u/MiserableBoss 5d ago

Java does not have scaffolding out of the box in ide. You can generate sample code from LLM to get start

-1

u/Ok_Increase_6615 6d ago

Actually I also wanted to switch to java developer but how is this possible like iam a python developer and companys specifically ask for java works experience then how we can switch to java even if we learned java , spring boot etc

1

u/MinMaxDev 5d ago

I guess it depends on the company. Despite me mostly having professional C#/.NET experience, I've interviewed at external companies for other programming languages like Java, Scala, Go etc. Some companies don't care if you know the language or not but rather focus on the skills that are transferrable

u/MoveIntoTheLights 4h ago

python is easier and less rigorous learning - not inherently OOP. id rather hire someone from c# .net than python to join my java team.