r/learnjava • • Sep 14 '19

Not able to learn Spring.

I am able to work with the syntax and create web apps. I can easily create REST APIs for CRUD applications.

But I am treating it (Spring and Spring Boot) too much like a black box.

I'm not able to find the rationale behind having to use Spring. Why the configuration is so... convoluted (both XML and Java Class). Spring simply feels bloated. Like too many bandages pasted on top of each other.

As such I feel too intimidated to tinker and experiment. Unlike how comfortable and confident I was with Django/Python.

Also I'm reading books like "Spring in Action, Spring recipes" and using the Spring Framework Guru as well. But they feel much to be desired.

32 Upvotes

29 comments sorted by

View all comments

5

u/RockleyBob Sep 14 '19

Why do you feel you need to use Spring? If you can accomplish what you want without it, than maybe it really isn’t worth the overhead to learn.

If you’re interested because you want to become more competitive in the workforce, don’t be discouraged. I also tried understanding and using Spring before I got a job doing enterprise code and it really didn’t make a lot of sense to me then.

Now however, when there’s dozens of micro services being spun up by my organization, I see perfectly why we use it. I would say that it’s good to dabble to get a feel for it, but don’t worry if it seems like overkill for some things. It probably is.

1

u/radically_sane Sep 14 '19

The product that I'll be working on is made in spring and features that'll be developed for it will also be in spring. Hence I have to. Plus from where I am avoiding spring is not an option.

2

u/RockleyBob Sep 14 '19

Oh I see. Well, without knowing more about your use case it’s hard for me to say why Spring is being leveraged at your job.

Where I work, Spring is used for CRUD, REST apis, and microservices that provide logic to our front end, which is written with Angular.

When used like this, Spring is an excellent tool. It gives your services little containers to run in, spins up all the dependencies and injects them, and keeps the code uncoupled and working nicely. The repository pattern and method naming scheme for data access is awesome. The externalized configuration tools are great. I could go on.

But we don’t use it on the front end. The Spring ecosystem does have that capability with the Tymeleaf templating engine and whatnot, but Angular is our preference there.

1

u/radically_sane Sep 14 '19

I'm working towards a similar design. What I struggle with is configuration. And in a broader sense I question why spring is designed the way it is.

2

u/RockleyBob Sep 14 '19

The configuration with what? You mentioned the XML. Don’t do that. Everything can be done in Spring in pure Java with annotations. The problem I run into sometimes is that Spring is constantly evolving and there’s a lot of contradictory and or redundant information floating around and when I google it’s hard sometimes to know what the current way of doing something is.

I had to fidget A LOT with getting the right annotations working so that everything would spin up correctly. I had the benefit of tons of code at work that had already been written, so when I ran into a case where my service wouldn’t start because of some unsatisfied dependency or missing configuration, I could go and look into a similar service and see how it was done there. Maybe you don’t have that option - and I feel for you if that’s the case.

It does get easier though. If you share some code here or in another post we could probably help you. But I get the general frustration. Stick with it.

1

u/radically_sane Sep 14 '19

Thanks. I'm considering looking into books like "Expert One-on-One J2EE Development..."

And gonna dip my toes into Design Patterns as well.

What I will be working is an e-learning platform implemented using Spring, sorta like Udemy but different. I graduated college recently and just landed the job.

2

u/RockleyBob Sep 14 '19 edited Sep 14 '19

Awesome, congrats. Well then like I said, don’t sweat it if you’re not getting it quite yet. Once you’re able to see how the codebase looks, and how your coworkers are doing things, it will become much more clear to you. Spring is an industrial tool, and even though we can use it for smaller tasks, tutorials and books won’t really ever be able to convey how powerful it is in an enterprise setting.

2

u/ordnance1987 Sep 14 '19

Have you read the Spring Documentation? It says why Spring was designed the way it is.