Spring Framework Introduction

Intro­duc­tion to Spring Frame­work -

I’d like to wel­come you to the Spring frame­work. Spring is the de fac­to frame­work today for writ­ing Java appli­ca­tions for both Enter­prise and inter­net appli­ca­tion devel­op­ment.

Spring Frame­work is first and fore­most open source, and that’s a very impor­tant thing to remem­ber as you devel­op your skills with­in Spring.

What is Spring ?

  • Open source.
  • Enter­prise and inter­net sup­port.
  • Light­weight.
  • Unob­tru­sive

When Spring first came out its pri­ma­ry focus was Enter­prise devel­op­ment, being a J2EE wrap­per for all of those com­po­nents so that you tru­ly could get right once run any­where oper­a­tion. But with a mod­ern Cloud com­put­ing, its Enter­prise sup­port has real­ly moved into both Enter­prise and inter­net.

Spring itself is very light­weight. The way that they break their projects up you only need to bring onto the class path those jars that you’re actu­al­ly going to lever­age.

If you don’t need Rab­bit sup­port you don’t bring it on, if you don’t need web sup­port you don’t bring it onto the class path and that’s very pow­er­ful.

Spring is also very unob­tru­sive. You can write a Spring appli­ca­tion and nev­er actu­al­ly bring a Spring import into a class file.

Now often we do bring Spring imports into our class­es because it makes devel­op­ment a lit­tle bit eas­i­er, but the impor­tant thing to note here is that you are mak­ing a con­scious deci­sion. You don’t have to do that ever with­in the Spring frame­work.

Spring in the Enterprise -

spring framework

It pro­vides all the sup­port for the stan­dard Java anno­ta­tions as well as Spring anno­ta­tions. Spring in the Enter­prise has a very large breadth of val­ue propo­si­tions. One of the biggest ones is that with Spring there is no need to run your Java appli­ca­tion on a heavy appli­ca­tion serv­er.

You don’t need web log­ic or web sphere to run a Spring appli­ca­tion because Tom, Cat or Jet­ty will pro­vide every­thing that you need. With Spring you don’t con­nect to tra­di­tion­al J2EE com­po­nents although you can, you stand those up as sep­a­rate com­po­nents with­in your entire Enter­prise and you con­nect to them through the Spring abstrac­tions.

It pro­vides all the sup­port for the stan­dard Java anno­ta­tions as well as Spring anno­ta­tions. Spring in the Enter­prise has a very large breadth of val­ue propo­si­tions. One of the biggest ones is that with Spring there is no need to run your Java appli­ca­tion on a heavy appli­ca­tion serv­er.

You don’t need web log­ic or web sphere to run a Spring appli­ca­tion because Tom, Cat or Jet­ty will pro­vide every­thing that you need. With Spring you don’t con­nect to tra­di­tion­al J2EE com­po­nents although you can, you stand those up as sep­a­rate com­po­nents with­in your entire Enter­prise and you con­nect to them through the Spring abstrac­tions.

Those abstrac­tions extend beyond Rab­bit mes­sag­ing for instance. There’s abstrac­tions for data­base providers, cash sys­tems, stan­dard SMTP mes­sag­ing, and any­thing else that you might think of in an Enter­prise sys­tem that you need. And if you run into one of those abstrac­tions that doesn’t exist, Spring pro­vides a very easy way to build a reusable client plat­form that you can inject into all of your Spring appli­ca­tions.

With Spring in the Enter­prise, you focus on the busi­ness and not repet­i­tive log­ic.

Think of how many times you’ve copy and past­ed all of your JDBC con­nec­tion strings from appli­ca­tion to appli­ca­tion because it’s the same code over and over. With Spring you’re not doing that which means when you actu­al­ly need to
go get data you’re focus­ing on the log­ic that your busi­ness needs, not the log­ic that’s repeat­ed over and over to do that.

Lightweight Nature -

spring framework

I men­tioned that Spring was light­weight in nature. That abil­i­ty to not lit­ter your source code with Spring anno­ta­tions is very pow­er­ful if you are in a sit­u­a­tion where you might change frame­works down the road.

Spring con­tin­ues to advance through all of their com­mu­ni­ty rela­tion­ships. Spring itself is small and bro­ken out and that in itself is very pow­er­ful. You can build a war or bet­ter yet an exe­cutable jar if you’re using Spring Boot, that only brings in those com­po­nents that you need to make your appli­ca­tion run.

We’re no longer fill­ing up file sys­tems with a bunch of use­less jars because we’re actu­al­ly using what we’re bring­ing in and Spring has dis­sect­ed their appli­ca­tion suite into a bunch of projects, so you real­ly only need to bring in the com­po­nents that you use.

Dependency Management -

spring framework

One of the most pow­er­ful things of Spring is the man­age­ment of your depen­den­cies.

The IOC con­tain­er which we’re going to talk about in the next tuto­r­i­al actu­al­ly man­ages all of your depen­den­cies at run time for you. Once they’re con­fig­ured you nev­er have to con­struct them again.

We no longer have to spend time in code man­ag­ing these depen­den­cies, we just sim­ply let the con­tain­er bring it in. And that in its own right is a huge per­for­mance improve­ment from the way that we tra­di­tion­al­ly wrote code, where we would con­struct our depen­den­cies, man­age its state through­out its life cycle and make sure that we clean it up appro­pri­ate­ly when we’re done.

So let’s get ready to look at Spring from the per­spec­tive of the IOC con­tain­er or this depen­den­cy man­age­ment sec­tion.