r/learnjava • u/Ariech • Oct 27 '21
Want to learn Spring!
I'm after MOOC both parts of the course. Now I'm thinking about diving in a spring framework.
Things that I know OOP (inheritance, polymorphism, interface, abstract class etc.).
What I know but didn't use that much (exception handling, packages, dynamic polymorphism)
And thing that I don't know is multithreading.
Now back to the question, I'd like to start with spring. How should I proceed with it? I found this https://spring.io/guides/gs/rest-service/, is it good for starting out? Should I find other resources or maybe stop learning spring and focus on more basic things? What would you tell are the prerequisites for learning spring?
Is spring.io guide enough for starting out? Does it provide with enough knowledge to start coding more complex projects for a beginner?
I'd be grateful for any resources to learn from.
12
u/HecknChonker Oct 27 '21 edited Oct 27 '21
https://docs.spring.io/spring-framework/docs/current/reference/html/
Spring has amazing documentation, and you can learn a ton from the overview and core sections. I was using the framework for a couple years before I read these, and I regret not doing so sooner.
The pieces you want to focus on are the spring context, beans, and dependency injection.
After that follow some spring tutorials, and then Google for tutorials that were relevant to the project you are working on.
Spring is huge, but you don't have to learn the entire thing all at once. You can start by just building the backend for a website and then slowly add stuff like authentication and security.
1
u/Ariech Oct 28 '21
Hey, it might be a silly question, but whatever. How do I use docs in the right way? Should I memorize these things, note them down, try to understand or maybe reference it when I need it? To be honest, I haven't needed to use docs for the most of the time. Sure, sure I've looked up a few things in Java, but I've never learned how to use them in the correct way :)
2
u/HecknChonker Oct 29 '21
I would go through the core and overview sections in detail, while trying to understand the concepts it's explaining. The rest can be used as reference.
There are a few things that are common between spring components. A context that stores beans, a dependency injection framework, and a set of configurations.
Beans are just instances of Java objects that are created by spring. You can use annotations to tell spring which classes it should create and add to the context and what the scope should be.
Dependency injection solves the problem of connecting different parts of your application together. Generally you want to separate controller logic, business logic, and data store logic into different classes, and dependency injection makes it easy to link it all together.
Let's say you have a class that loads user information from an database called UserDAO. You might need to call methods that belong to this class in a dozen places, and the DAO needs to store state that allows it to obtain database connections.
Spring boot adds a bunch of smart default configurations that make it really easy to build things out. As an example, if you provide the three config values below spring boot will add a JDBCTemplate object to the context that makes it easy to run queries against that endpoint. If you add that JDBCTemplate to the DAO constructor spring will instantiate that DAO and inject the template in automatically, and the inject that instance of the DAO into every service and controller object that needs it.
spring.datasource.url=jdbc:mysql://localhost:3306/springjdbc spring.datasource.username=guest_user spring.datasource.password=guest_passwordEach spring module makes use of annotations, configs, and the spring context while extending them to support new features. Like batch processing in a shell script, or processing streaming messages from message queues, or building backend REST or graphql APIs, or adding authentication and authorization, or adding performance monitoring and observability.
Each of these areas can be learned when you need to use them, but it's helpful to have a brief overview of them so you know what's possible.
If you ever have questions, start by googling and look for articles on baeldung. They are short but contain high quality concise answers. Also feel free to ask on Reddit.
6
u/alcosexual Oct 28 '21 edited Oct 28 '21
Hey there! I was in your shoes not too long ago and now I’m a Java/Spring developer for a pretty big e-retailer.
In college we focused mostly on Java, so naturally I wanted to develop some familiarity with Spring because I saw so many job postings asking for Java/Spring experience.
So I got online and followed along with some Lynda courses and did some Spring tutorials and I dutifully typed the code they told me to type… and it was good. Sorta.
Except… well, even after I did all that, I still wasn’t quite sure what Spring actually was.
I knew that I could create classes and Spring could "autowire" them in for me without having to instantiate them. I knew I could use various modules like Web and Data to make writing some things easier…
But… the benefit of this massive ecosystem still wasn’t all that clear and I felt silly for not seeing the benefits. I read again and again about dependency injection and inversion of control (IOC) and just didn’t get why this was really all that great.
Now, however, I understand that Spring is all about getting stuff done quickly while keeping your code clean and maintainable.
This is really important. The reason I wasn't understanding Spring during my time as a student was because I really didn't have any need for what Spring offered. Therefore, I could do as many tutorials and read as many articles as I wanted, but Spring was never really going to "click" for me until I saw it being used in a professional environment.
Spring allows dozens of developers to make applications for specific business needs that can be written quickly, and any developer with knowledge of Spring can quickly understand a Spring project because they all look somewhat similar to each other. Spring gets rid of tons of "boilerplate" code that can clog up classes and make reading code more tedious. Because Spring is taking care of lots of annoying trivial tasks in the background, developers can write cleaner code in less time. Applications are more easily understood by people other than those who wrote them.
So, I'm sorry to write all that and not really answer you question, but the truth is learning Spring is pretty pointless without first knowing why you need Spring. Other people have pointed out tutorials and demos you can do, and there's nothing wrong with giving them a try, but in the end your projects won't necessarily be better just because you made them with Spring. The downside of Spring is that it can hide away a lot of what's it's doing behind the "magic" of boot strapping and auto configurations. So becoming dependent on Spring to set up your database modeling or your REST controllers might actually hurt your learning progress.
I'm not saying you shouldn't familiarize yourself with it! Just that I was probably a little too worried about using it early on and it really doesn't start to make sense until you're working with other developers in a business setting. If you do want to learn Spring, it's best to think about an application or use case that you'd like to build, and then see how Spring can help you achieve that goal, rather than attempting to learn it for the sake of knowledge.
Hopefully that makes sense, I'm not trying to discourage you, only to help guide you in a good use of your time. Feel free to ask if you have more questions.
3
u/Ariech Oct 28 '21 edited Oct 28 '21
Hey, thanks for your answer. I get what you mean about not that much use of spring for somebody like me right now. But let's face the truth, it's required to get a job, at least in my country. As you said in your post, you learned the value of spring after getting into proffesional enviroment, without spring it's mostly impossible where I live. I can't even get paid internship for an university without basic knowledge of that framework. So I'm a bit under pressure to learn it even though I might not find specific uses for it in my projects. Don't get me wrong, I do have a few projects ideas in my head. Spring framework is quite interesting for me too, at first I started with frontend back in the days. It wasn't something that I enjoyed that much, but I wanted to develop websites.
8
u/Ryze001 Oct 27 '21
Amigoscode (yt and website), java brains (yt)
And this video I'm currently following too
1
4
u/cantseemtosleep Oct 27 '21
Strongly recommend learning Spring/SpringBoot. I learned it (using that loosely here) in my intermediate and advanced java programming courses in community college. Amazing technology and very powerful. Combined with MVC and you can build fantastic, enterprise-level applications more or less from scratch without killing yourself coding forever.
There's a lot to it though and it can be overwhelming at first so just keep trying, start slow and take your time. Good luck.
1
u/Goldman7911 Oct 27 '21
Same boat, I've started reading book "Spring Start Here, Manning Publications" and also trying to figure out spring's huge documentation.
1
u/Ariech Oct 27 '21
Do you have any previous experience with programming or just mooc was your first?
How's the book? Can you follow it easily, struggling?
1
u/Goldman7911 Oct 27 '21
I have network background and used to scripted langs as Python & JS. The book really helps grasp Spring's important aspects. Too many people say "after you understand this in Spring, anything in the ecosystem is the same bla bla"
2
u/madnessguy67 Oct 27 '21
If you're like me and like to learn from courses HyperSkill has a project introducing Spring
1
u/nine_thousands Oct 27 '21
RemindMe! 1 week
1
u/RemindMeBot Oct 27 '21 edited Oct 28 '21
I will be messaging you in 7 days on 2021-11-03 15:55:38 UTC to remind you of this link
2 OTHERS CLICKED THIS LINK to send a PM to also be reminded and to reduce spam.
Parent commenter can delete this message to hide from others.
Info Custom Your Reminders Feedback
1
1
1
1
•
u/AutoModerator Oct 27 '21
It seems that you are looking for resources for learning Java.
In our sidebar ("About" on mobile), we have a section "Free Tutorials" where we list the most commonly recommended courses.
To make it easier for you, the recommendations are posted right here:
MOOC Object Oriented Programming with Java from the University of Helsinki
Java for Complete Beginners
accompanying site CaveOfProgramming
Derek Banas' Java Playlist
accompanying site NewThinkTank
Hyperskill is a fairly new resource from Jetbrains (the maker of IntelliJ)
Also, don't forget to look at:
The official Documentation
The official Java Tutorials
Our community resources thread
If you are looking for learning resources for Data Structures and Algorithms, look into:
"Algorithms" by Robert Sedgewick and Kevin Wayne - Princeton University
Coursera course:
Part I
Part II
Coursebook
Algorithms 4th Edition
Your post remains visible. There is nothing you need to do.
I am a bot and this message was triggered by keywords like "learn", "learning", "course" in the title of your post.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.