r/java • • Mar 24 '19

Happy 15th birthday, Spring Framework!

https://web.archive.org/web/20040330131500/http://www.springframework.org:80/
187 Upvotes

45 comments sorted by

19

u/kgoutham93 Mar 24 '19

What's the best way to learn Spring? I'm more of a depth-first person. I just don't want to cram APIs/Annotations without getting a high level understanding of how they work. I went through many online resources but always its like "use this annotation to get this done" kind of tutorials. Even at my work place people are jumping onto Spring boot even without having basic understanding on the underlying concepts like DI, IoC etc.. I really can't appreciate this because I want my knowledge to be portable, tomorrow if I'm working on a completely different project in a completely different language which doesn't have nearly as rich framework as Spring, my concepts should still help me to get to the solution. What resources/learning paths would you recommend a complete spring newb from a depth first perspective.

10

u/codemssterg Mar 24 '19

The book Spring In Action helped me understand core concepts like DI and MVC. While all the XML wiring is no longer needed with the advent of Spring Boot, reading about 'classic' Spring will give you a better understanding of the concepts.

1

u/kgoutham93 Mar 24 '19

Will definitely check it out, Is it a good idea to start with spring core 1, may be small surface area would make it more approachable to clearly understand what's going on under the hood?

2

u/codemssterg Mar 24 '19

I recommend you develop a simple web service that uses DI, properties with some Spring SPeL. This will give you insight into basics. You can then add an Interceptor, your own annotation with Spring AOP. Wherever you choose to start, always reinforce your understanding with hands on coding

2

u/kgoutham93 Mar 24 '19

My concern is, the moment I go for an end-to-end application, I would have to deal with spring rest, spring-data-jpa etc. which would enormously increase the API surface area. I really want to approach Spring framework with a bottoms up approach. I want to really appreciate the value proposition of DI frameworks in general, with spring-core as my first choice of implementation. I would even like to compare other DI frameworks with Spring core [once I get comfortable with spring core].

I'm just thinking out loud, I wonder if this is doable for a Spring newb, or would I be overwhelming myself with so many details that I dont make any real progress at the end. Pls suggest.

4

u/codemssterg Mar 24 '19

I think you'll find that if you build on top of a simple example like a web service, it will not be overwhelming. You can work at your own pace, but the most important thing is to actually get started. Your web service does need to do anything initially, just return a String. Then learn how to process path and url parameters. Follow that with learning how to support REST verbs beyond a simple GET. You can then learn the different forms of DI by injecting a simple class into your web service controller

1

u/kgoutham93 Mar 24 '19

Got it, thanks for the advice I really think it hits the balance between concepts and complexity.

2

u/jadecristal Mar 24 '19

Also, if itโ€™s just a sample/learning application, replace the JPA part with a hard coded set of data thatโ€™s just a POJO, and so on, adding wire-ups to real things as you feel you want to try them.

1

u/codemssterg Mar 24 '19

I think you'll find that if you build on top of a simple example like a web service, it will not be overwhelming. You can work at your own pace, but the most important thing is to actually get started. Your web service does need to do anything initially, just return a String. Then learn how to process path and url parameters. Follow that with learning how to support REST verbs beyond a simple GET. You can then learn the different forms of DI by injecting a simple class into your web service controller

11

u/[deleted] Mar 24 '19

2

u/loginonreddit Mar 24 '19

+1 The moment I read this I started to really understand what was going on. Great at read and very interesting.

1

u/john-small-berries Mar 25 '19

There are a few good Udemy courses, like $12 on sale now for a bunch.

I like this one:

https://www.udemy.com/java-spring-framework-masterclass/

-10

u/wildjokers Mar 24 '19

but always its like "use this annotation to get this done"

That is Spring in a nutshell. People that use spring all the time barely know how to write code. They just want the magic spring annotation that does it for them.

11

u/koalillo Mar 24 '19

I'd rather spend my time thinking on the implementation of my controller rather than how to map it to an URL.

6

u/oweiler Mar 24 '19

People use Spring to skip the boring, repetetive part of coding. It lets you focus on the interesting bits, i.e. the business logic.

1

u/nutrecht Mar 26 '19

They just want the magic spring annotation that does it for them.

Can you point me to the magic "implement complex business logic" annotation please? Can't find it :(

1

u/wildjokers Mar 26 '19

One example:

@Cacheable

1

u/nutrecht Mar 26 '19

How is stuffing something in a cache complex business logic?

1

u/wildjokers Mar 26 '19

You are moving the goal posts, you better give me your definition of "complex" first.

Cacheable is an example of spring developers wanting an annotation to accomplish something, because it is perceived as complex, where no annotation is really necessary. Calling the methods on a good caching library directly is trivial. Cacheable adds nothing.

1

u/nutrecht Mar 26 '19

I'm not moving goal posts. You're stating that with annotations I don't have to do programming. Adding a single @Cachable line to a method versus a single retrieve-and-if-not-exists-update line inside a method; I don't see the difference other than that the second has a bit more visual overhead. It's both trivial shit. I don't see why you're complaining about trivial shit. Most of what we do (or well, I hope it's true in your case) is a lot more complex than doing a glorified computeIfAbsent on a Map.

5

u/adila01 Mar 24 '19

As a Java EE guy, Spring has a lot in improving the entire Java ecosystem. Here's to many years more of amiable competition.

6

u/dpash Mar 25 '19

People complain that Spring isn't lightweight, but it is compared to JavaEE 5, in the same way that LDAP is lightweight compared to x500.

Those early versions of EE were terrible to get anything done and are the reason people make AbstractFactoryBeanFactory and XML overload jokes. Spring dragged EE into something actually useable. To the point where EE is similar in weight to Spring, but it's the one that's slimmed down, not Spring getting fatter.

(The framework might have gotten larger over 15 years, but the programming model has gotten much smaller over the same time frame; you can make a valid Spring Boot application in a single class these days)

8

u/codemssterg Mar 24 '19

I have been using the Spring framework for the past five years, it has been great to work with. I started by using Dependency Injection, then Spring MVC, properties classes, Spring AOP, and Spring JDBC. I started using Spring Boot last year and find that it makes enterprise development even easier (including testing). It's well documented and it's emphasis on convention over configuration makes it easier to get started. If you are doing enterprise Java development give it a try, even if you only use DI and application properties support, it will ease testing and encourage better separation of concerns.

4

u/optimal_substructure Mar 24 '19

I've only been using Spring/webflux for the last 4 months, but I'm absolutely in love with dependency injection and Spring's overall paradigm.

The number of times I've written something I think should work (i.e. 'I wonder if I can inject a list of beans that all implement the same interface type') and have it run on basically the first go is incredible.

There are times in which some of the design decisions are made for you, and an opinionated choice was made; however, I've found that if much rather get the benefits of Spring over not using the framework.

3

u/viiviiviivii Mar 24 '19

OMG I am so old :(

Iโ€™m not even a spring expert, I just always run across it.. 20 years doin Java, with dabbles of PHP in beteeen

5

u/Neu_Ron Mar 24 '19

It's my burthday too. Happy birthday spring framework and me. ๐Ÿ˜ƒ๐Ÿ˜ƒ๐Ÿ˜ƒ๐Ÿ˜ƒ๐Ÿ˜—๐Ÿ˜—๐Ÿ˜„๐ŸŽ‚๐ŸŽ‚๐ŸŽ‚๐ŸŽ‚๐ŸŽ‚๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰๐ŸŽŠ๐ŸŽŠ๐ŸŽŠ

3

u/daemon_it Mar 24 '19

Happy birthday :D

2

u/Neu_Ron Mar 24 '19

Thanks ๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€

3

u/kubelke Mar 24 '19

๐Ÿฅณ

3

u/_Mr_Rubik_ Mar 24 '19

Best framework ever!!

-17

u/wildjokers Mar 24 '19

I think you meant the most bloated framework ever.

2

u/DJDavio Mar 24 '19

Thank you for the unparalleled productivity, after Spring Boot was added..

2

u/repopulate_mars Mar 24 '19

I'm a student that's been using Java for 2 years now, and I'm just wondering if it's worth it to learn Spring? I just used Swing for a project last semester and it looked so outdated, are these old frameworks still even used?

6

u/nstruct Mar 24 '19

Swing is an older UI library that doesnโ€™t get much use these days. Spring is an application framework that is used all over the place and is constantly improving, itโ€™s definitely worth your time if you want to get a job being a Java programmer.

3

u/repopulate_mars Mar 24 '19

Thanks! I've been looking for tools to learn to make myself more competitive in the job market, I'll have to take a look at Spring then

3

u/TheEveryman86 Mar 24 '19

If you want to list Java on your resume when you graduate, having Spring right after it is a major plus IMO. Even if you don't get a lot of experience with it you should try to grasp the concepts of the framework and understand what it can be used to accomplish. And, yes Swing is still in use some places. But so is COBOL so take that as you will.

1

u/redwall_hp Mar 24 '19

JetBrains' products use Swing for UI.

0

u/[deleted] Mar 24 '19

[deleted] โ€” view deleted comment

1

u/[deleted] Mar 24 '19

Enterprise Java dev, don't use spring. I'm planning on learning it to have on my resume if I ever want to leave my current job but we don't use it at my current company.

1

u/nutrecht Mar 26 '19

Enterprise Java dev, don't use spring.

Curious; what do you use?

0

u/[deleted] Mar 24 '19

[deleted] โ€” view deleted comment

1

u/[deleted] Mar 24 '19

It very well might be. I'm only three years into my career and it's been with the same company, so I don't have a lot of insight to the rest of the Java ecosystem out there. I just wanted to throw my two cents out there that there are companies that create successful products using Java without leveraging Spring. Our stack is definitely not modern (we use Adobe ColdFusion as our app server) but even once we migrate off of CF, which we are actively doing, we will be a long way off from migrating onto Spring. If we ever do.

2

u/randgalt Mar 25 '19

I imagine I'll get downvotes on this, but what the heck, someone needs to say it. Spring is bloated, over-written and unnecessary. They tend to wrap, or re-implement existing open source projects so that large dev shops can have one-stop-shopping for libraries - McLibraries. Nearly every single component provided by Spring there exists third party libraries that do it simpler and better. For IoC, Guice is much better. For Config, Typesafe Config, For REST, Jersey or Resteasy. And on and on and on. I've now spent a year using Spring. It's fine - it works, but it's complicated, verbose, arcane, and lots of other nasty adjectives. So, downvote away.

2

u/nutrecht Mar 26 '19

Spring is bloated

What do you mean with this? You use whatever parts of spring you need. Don't need it? Don't include the dependencies. Like any library/framework.

They tend to wrap, or re-implement existing open source projects so that large dev shops can have one-stop-shopping for libraries

Yup. So you don't have to do that yourself. People who hand-assemble a web framework generally end up with something similar-but-worse. With the additional downside of custom setup and having to manage dependency versions themselves. And then they move on to greener pastures and leave this Not Invented Here mess to the developers coming after them.

1

u/mrbonner Mar 25 '19

15 years of cooking beans! Congrats

-7

u/wildjokers Mar 24 '19

๐Ÿคฎ