Getting Started with Spring Tutorials

Spring Tutorials Java Cup

After spending 11 years working on Spring Framework projects, a pattern started to emerge for me.

I started drinking more coffee. 2-3 times per day. At least.

The coffee beans became so much more appealing in the last few years. They weren’t bitter anymore. The taste is more silky and smooth now. These weren’t just cups of “java” for me. They became part of daily routine in my life. I have a cup right next to me as I write this.


Hi!. I’m Amit Sharma. I am the creator aka java sipper at springtutorials.com

Springtutorials.com will provide you with everything you need to become a Spring Framework Expert.

Here you will start with simple topics like ‘how to auto wire a bean’. And then move on to big data topics such as ‘how to handle tens of millions of data points’ for better retrieval. And along the way, you will explore ‘how to scale your applications to handle millions of users’. The whole nine yards.

Why springtutorials.com?

I have been a java developer for 15+ years now. Most of it is web development. 11+ years of it was java spring in some form or the other.

The rest was Struts. And some plain old servlet programming. And some even involved back office implementation with no web interface.

But it was Spring Framework most of the time.

Spring Framework came out in 2002. I have been using it since late 2004. You can learn more about my story on this page. In the post, I share how I came across Spring Framework and what made me believe in it from the early days.


 

I confess. I have become Spring Beans addict. I was pitching Spring JDBC at my work in 2005!

It was a hard sell back then but well worth it. I still get mentions from that team even today for introducing it back then. My co-workers have long known me as a CRASH DEV DUMMY of the tools and technologies.

I am always trying new tools.

Always evaluating new technologies.

That’s just my way of learning. I can’t help it.

The Problem

Oh, I almost forgot about the pattern discussion above. I was saying a pattern had started to emerge.

So, Team members over the years started approaching me with questions about Spring Framework.

Actually Questions not just related to Spring Framework. But also about other technologies that come into Spring ecosystem.

Some questions were simple and easy to answer.

Q.1 “Where should the Spring Transactional @Transactional annotation go? In your Services, Controller or Dao layer?” 

A. Service layer.

Q.2 “I don’t see any Spring Data Repository implementation for findByNameAndDescriptionAllIgnoreCase?”. 

A. Correct.

Q.3 “I use jQuery or AngularJS on the front-end. How do I convert my data from hibernate entity into JSON (also known as Marshalling) ? “. 

A. You don’t need to. Spring MVC + Jackson will do it for you. 

 

At times, there were questions that were easy to answer but weren’t intuitive. See below for what I mean.

Q.4. “I have a service defined as a bean in an XML. I want to call it in an annotated @Controller. Can I use @Autowired?”. 

A. Yes.

Q.4a. “And I don’t need a getter setter?” 

A. Correct.

The answer is simple.

But you couldn’t find something like this in books. Books usually follow a pattern in their versions.

A book covering Spring 4.0 will cover the annotations based approach. And Book covering Spring 3.5 covered the XML approach prevalent then.

Book with Spring 4.0 mentions the transition from XML into annotations. But it may not address the hybrid approach.

You get the point.

 

Also, there were few questions related to things that a developer does besides coding. These were about tools that help developers do their task faster and better. I will pick few with short answers below for brevity sake and explain what I mean.

Q.5.“How do you find the jar where this class resides, in no time?”. 

A. CTRL-SHIFT-T in eclipse. Use eclipse keymap in IntelliJ.

Q.6.“Which tool did you use for annotating these screenshots?” 

A. Skitch.

Q.7: “I am a Java / Spring developer. What is the best way to download Oracle on my laptop?”  let’s hear the next two questions. I can answer them together.

Q.8: “I am on windows. How do I simulate Linux environment?”  

Q.9: “How do I test my application on IE6 or other IE versions I don’t have?”.  

Let’s answer them in one swoop below.

A: Download Oracle VM VirtualBox.

A7. Look for pre-built VMs on there. Oracle virtual machines are available for download from Oracle website.

A8. Or mount the iso image of  your favorite Linux flavor there. Once you create a container, you can point it to a Linux distro you have available.

A9. Or install pre-built virtual appliances from modern.ieThese VMs are available from Microsoft and come with different browser versions.

Do you see a pattern with the questions above?

I did and it is as follows:

You won’t find answers to these questions in a book. Definitely not in any Spring book.

These are just recommendations from someone who has exposure to these tools and technologies.

My answers led me to mention tools that I believe are great and tips that solved the problem for me.

You may have a different tool set or solutions that would do the job just as well or even better.

But the point is these questions do come up. And they come up more often than you think.

If you are just starting out in the industry, you are asking them yourselves. Right?

And I am only including questions that are quick to answer here.

Let me list few more long ones that may help get the point across. I won’t answer them here. See below.

Q. Should I use client side or server side validation…..?

Q. Should I use JSP to handle server-side logic or use jQuery and do it in the javascript……?

Q. Should I use Oracle or MySQL….?

Q.What is the difference between Eclipse and IntelliJ…..

Q. Give me a reason to use NoSQL vs Oracle……. Which NoSQL?

Q.What can MyBatis do that Hibernate can’t…..?

Q.Why is Session bad? what does it mean to be stateless …..

Q. Which one do you prefer: Apache or Nginx….?

Q.Why would anyone use anything other than Tomcat or JBoss…?

Q.Which one is better: Jenkins or Bamboo…..?

Q. I am used to Ant. Give me a reason to use Maven….?

Q.Where can I host java applications? Amazon or Rackspace…. What about other vendors?

And the list goes on…

So, Let me ask you this. Where would you find answers to these questions?  Can you find them in books or spring.io guides?

I know they are not all related to Spring Framework. But a Java / Spring Developer is asking them. Correct?

And I can guarantee you won’t find them in one single place.

Let’s dig a little deeper.


 

I also ran into questions that were hard to answer.

The answers to these questions weren’t a simple yes or no type. Some of the questions I asked above fall into this. They depend on data and design considerations.

See a perfect example below.

Q.10 Should I use jQuery or Angular JS for my application?

The answer is dependent on several follow-up questions. 

How much data exchange is going on between  your server side and client side?

How often is data exchanged? 

Who is your target audience?

Are they web savvy?

What browsers do they use?

Are your developers HTML5 / CSS3 coders?

Are they open to picking up CSS Framework like Bootstrap for consistent design as well?

In most places I have worked, Spring Developers are also doing the HTML coding and writing CSS styles. There is no UI/UX Team there. 

Angular JS is a javascript MVC (model view controller) like framework

jQuery is a javascript library

Angular JS would make your design single page application.

The Two-way data binding in Angular JS makes manipulating form data easy and intuitive.

But the pages are now swapped in and out of DOM. If your application is data intensive, the page swapping may not be ideal. 

Angular JS is awesome. But there is a slight learning curve with AngularJS.

jQuery is simple and easy to learn.

But it doesn’t support the robust MVC or the related MVVM architecture. Your development time may go up.

Or Maybe not. With jQuery, you could continue using JSP.

You could bring jQuery only for front-end validation and data fetching via Ajax. Rest all can still stay server side. 

Angular JS dropped support for IE8 or below recently.

jQuery split their framework into two. One version still supports IE5 or above. The other one does not.

Angular JS recently split as well. The new angular is bringing some new changes to the framework.

Some of these changes are not backward compatible.

Angular JS could run into version issues.

Remember Tapestry. 

Spring Tutorials - Angular JS vs jQuerySo Which one did you pick? AngularJS or jQuery. Am I making sense? Read on.


 

Some of the arguments in answering a question that is not a simple yes or no become subjective at times.

Developer Forums like Stack Overflow would take down such opinionated discussions in no time. And for a good reason.

A developer’s opinions come into play with questions about picking from two implementations.

Their familiarity with a tool or framework becomes a big weighting criterion.

Most book authors lay down the facts and not provide an opinion one way or the other for this reason.

The spring.io guides are a refreshing and a wonderful source for learning Spring Framework.

I like them a lot.

They provide a short and complete example of the topic on hand. I believe a Spring Developer cannot afford to not try them out.

And there are several books on the topic available that are well written.

There is no shortage of blogs out there that can provide well-defined implementations.

Short snippets or simple examples of anything are available on Stack Overflow. I am always googling ‘ my tech question + stack overflow’

But I also believe they solve only one equation of the problem well: Implementation. I like to call it just ‘code‘.

The implementations are only part of the answers to the questions I ran into.

Spring Developers

Please do not underestimate the role of Spring / Java Developers.

I have worked at two places now where there was no DBA. Who did the database work then?

I have already said it above. Most places don’t have UI/UX developers. Who writes the front-end HTML/CSS/Angular JS/ jQuery and other code?

In few of my projects, I was Ops guy as well. I built, deployed and supported different environments. DevOps FTW!

Few years ago, I was also customer-facing for one client. I would go to clients to collect requirements. I would come back and code the solution. I would coordinate with the deployment team to push the code. I would go back to the client and demo it. Rinse and repeat.

Let me say this so I feel better.

All java developers are testers by default. Not the best testers in the world but we do perform testing and that takes time away from coding.

If Spring Developers are doing more than just java coding as I explained above, Do they have time to research everything I asked above? I wish I had these answers in one place when I was starting out.

Spring Tutorials - Spring Developer

The Solution: Spring Tutorials

We are missing a voice that can tell us what works best and why. And that can only come from complete knowledge of the subject.

This knowledge or awareness comes from developing a rule of thumb after careful design considerations over time.

Books usually shy away from discussing preferences. Speaking of books. I want to go back to our discussion of good Spring books that are out there.

I may be stating the obvious here. But I am not seeing developers with books in their hands these days.

Google helps out a lot here with quick searching.

I am not saying it is a bad thing.

A developer with a comprehensive knowledge of the subject can fill in the gaps this way in a short period of time. An out of touch developer can get up to speed in a matter of hours or few days. Thanks to Internet.

In comparison, Most technology books are 400+ pages long. Some get outdated as soon as they are in print. And with the proliferation of the web, the information overload is not helping.

I remember buying a book on Groovy several years ago. I read the whole book. And then I decided to try out the examples. Oops.. 40% of the code did not work. All the simple examples worked.

The groovy version I downloaded was an upgraded version. Some of the method calls (APIs) weren’t there. Others worked in a different signature.

It is hard to find good quality content in a digestible manner without books. But books aren’t on developer’s radar in my opinion.

I could be wrong. I don’t have any book sales data to back up this claim.

I do know that developers have no incentive to gain complete picture when they can get local with sub-topics.


 

Also, a complete picture is a relative term even with books.

A book about Spring MVC may not even mention Jersey. So, a Spring developer may never get the complete picture of all the options anyway.

As a result, our best practices criteria isn’t complete with Implementation alone.

Our rule of thumb is inaccurate.

Our judgment is incomplete.

Noble Laureate Daniel Kahneman has a term for it. He called it the ‘heuristics bias‘ in his famous book: ‘Thinking, Fast and Slow‘.

Check out the book. It is one of my favorite books of all time.

welcome to www.springtutorials.com

So, I decided to provide a complete picture and share all I know. And I created springtutorials.com with the following goals in mind:

  • You will get a deep dive into the Spring Framework and its various modules. Short Guides on Spring MVC. Quick Tutorials on Spring Integration. Cheat Sheets on Spring JDBC. Book reviews on the subject. In short, I will share everything that will help you become a better Spring Developer.
  • You will get the quality comparison of different alternatives that exist in space. So, Spring MVC vs Jersey for example. Spring MVC vs Struts. Why are they similar. Why are they different. What niches do they support? What are exceptions in each argument? What are other options to consider. Which one is better. And Why?
  • You will get tips and tricks along the way. Tips not just about code shortcuts or IDE hacks. But tips that will help you improve your Spring skills along the way. Tips that you can follow to be smart about how you do software development.
  • You will get my honest opinion on topics. If I am involved in any of the topics, I will share that up front. If there is an industry standard, I will share that for sure.
  • I will provide my unbiased assessment of tools or technologies. If I don’t know something, I won’t claim otherwise. I will share what I do know and will ask for help from you to fill in the gaps. I am always learning a new tool or technology every day from developers around me. There are things I don’t understand and I will expose those in my posts in the open.
  • I will help you become a well-rounded Technologist. My focus will be on Spring Framework. But you will want to know about so many other things for your own betterment. Databases – SQL, in-memory or no SQL types. Front end technologies. Different software development practices like Agile or Waterfall. Build tools. Different Operating Systems. Application Servers. Testing. Requirements. Documentation. Other languages. Other frameworks and libraries. These will become individual and detailed posts at some point.

I am here to help you reach your career goals.

I want to help you become best at what you do.

My focus here is to guide you in your career path.

Thank you for visiting my site.

I want to mention that I love meeting new people – online or in person. Please stay in touch. I would love for you to connect with me. Even if for a few seconds, Please come and say hi on facebook here.

Let me know if there is anything I can do. And don’t be shy. I look forward to hearing from you.

Amit Sharma