In 2002, the Aus­trali­an developer Rod Johnson presented the code of the Java framework Interface21, which he had written spe­cific­ally for his own projects, in his work “Expert One-on-One J2EE Design and De­vel­op­ment”. On the basis of this code, he later developed the Spring framework, together with other pro­gram­mers, which was released for the first time under the free Apache 2.0 license on Source­Forge in June 2003. It’s still one of the most popular solutions for the de­vel­op­ment of en­ter­prise ap­plic­a­tions in Java. The open source framework has since cleared up the weak points and limits of the standard de­vel­op­ment en­vir­on­ment J2EE (now also known as the “Java platform”) as well as the component model En­ter­prise JavaBeans (EJB) by sig­ni­fic­antly reducing their com­plex­ity.

What is Spring?

Spring sim­pli­fies the de­vel­op­ment of Java ap­plic­a­tions – re­gard­less of whether they are offline or web ap­plic­a­tions. The biggest ad­vant­ages of this framework are its lean source code and the minimal effort required for ad­just­ments. These comforts are provided to the pro­gram­mer based on the following prin­ciples, which are explained in Rod Johnson’s book:

  • De­pend­ency Injection (DI): De­pend­ency Injection refers to the external instance in object-oriented pro­gram­ming, which controls the de­pend­en­cies of the objects. Spring uses the Java component JavaBeans for this. They function in Java as a container for data transfer, which is why they serve as a template for all managed resources (“beans”) in the Spring framework. In this way, Spring can act as a container that provides pre­con­figured classes, including their de­pend­en­cies, to the Java project.
  • Aspect-oriented pro­gram­ming: To increase the mod­u­lar­ity of object-oriented ap­plic­a­tions even more, Spring also offers optional aspect-oriented pro­gram­ming ap­proaches which use the AspectJ language. This allows aspects, or cross-component con­nec­tions, which are in­ev­it­able in complex systems, to be struc­tured syn­tactic­ally. This has the advantage that the actual programme code can be separated from technical processes such as error handling, val­id­a­tion, or security.
  • Templates: Templates in Spring are denoted as classes for various programme in­ter­faces, and simply the work with APIs by providing automatic resource man­age­ment, uniform error handling, and other help.

By following the prin­ciples outlined above, the Spring framework allows de­velopers to access Plain Old Java Objects, or POJOs (or common Java objects) when de­vel­op­ing En­ter­prise Java ap­plic­a­tions. As opposed to the En­ter­prise JavaBeans (EJBs), POJOs don’t need a specific ap­plic­a­tion server that supports the EJB con­tain­ers – standard solutions such as Tomcat are com­pletely suf­fi­cient. To use Spring, you also need the Java SE De­vel­op­ment Kit (SDK).

Spring: In­tro­duc­tion to the most important module

For many ap­plic­a­tions in Java, Spring is the perfect choice – mainly due to the modular structure of the framework. Around 20 modules are available for de­vel­op­ment with Spring. You can freely choose which com­pon­ents you need for your ap­plic­a­tion and which you don’t. In the standard con­struc­tion, the different modules are separated into the following six cat­egor­ies:

  • Core container: The core container includes the ele­ment­ary modules spring-core, spring-beans, spring-context, spring-context-support, and spring-ex­pres­sion. Core and Beans build the basic outline of the framework and contain, for example, the de­pend­ency injection function as well the POJO support. The context module inherits its features from the Beans module and adds functions to the ap­plic­a­tion, for example, for in­ter­na­tion­al­isa­tion or loading of resources. In addition, Java En­ter­prise features like EJB and JMX (Java Man­age­ment Ex­ten­sions) are supported. With the help of context-support, libraries from third parties can be joined with Spring. Spring-ex­pres­sion contains the Spring Ex­pres­sion Language (SPeL), a de­vel­op­ment of the Unified Ex­pres­sion Language of the JSP 2.1 spe­cific­a­tion (JavaS­erv­er Pages).
  • AOP and in­stru­ment­a­tion: To enable aspect-oriented pro­gram­ming, the Spring framework contains the module spring-AOP as well as the module spring-aspects for the in­teg­ra­tion of the pre­vi­ously mentioned language AspectJ. The spring-in­stru­ment component allows you to in­stru­ment­al­ise Java classes – that is, to change bytecode at runtime – and also adds Class­Load­er im­ple­ment­a­tions for different ap­plic­a­tion servers.
  • Messaging: To function as the found­a­tion for message-based ap­plic­a­tions, Spring has some key features of the key Spring In­teg­ra­tion project – such as, for example, “Message”, “Mes­sageChan­nel”, or “Mes­sage­Hand­ler”. The cor­res­pond­ing module is named spring-messaging.
  • Data access/in­teg­ra­tion: The modules in this category are designed to give Java ap­plic­a­tions the ability to interact with other ap­plic­a­tions and manage data access. The module spring-JDBC, for example, provides an ab­strac­tion layer that defines how a client accesses the database and elim­in­ates the need for a cum­ber­some JDBC coding. Spring-ORM, on the other hand, provides in­teg­ra­tion layers for popular ORM in­ter­faces that allow access to re­la­tion­al databases. The other com­pon­ents are spring-TX (supports programme trans­ac­tion man­age­ment for all classes and POJOs), spring-OXM (ab­strac­tion layers for object/XML mapping), and spring-JMS, a module with features for the pro­duc­tion and handling of messages.
  • Web: In this category, you’ll find the web ap­plic­a­tion-specific modules spring-web, spring-webmvc, and spring-websocket. The first adds the typical web-oriented in­teg­ra­tion features to the Java ap­plic­a­tion, such as an upload function for multipart data or an HTTP client. The spring-webmvc module is also referred to as a web servlet and contains the Spring im­ple­ment­a­tions for the real­isa­tion of the standard model view con­trol­ler ar­chi­tec­ture and the REST web services. Spring-websocket enables data transfer between client and server on the basis of Web­Sock­ets.
  • Test: The spring-test module makes it possible to check the func­tion­al­ity of the com­pon­ents of your Java ap­plic­a­tion. With the cor­res­pond­ing sup­ple­ment­ary frame­works, such as Junit or TestNG, you can perform extensive unit tests (with the focus on a single component) as well as in­teg­ra­tion tests (with the focus on the interplay of several com­pon­ents).

Spring: Java in modern web de­vel­op­ment

From the beginning, Java, including the tech­no­lo­gies related to it, was designed for use in web de­vel­op­ment. After start-up dif­fi­culties due to the low support levels of earlier browsers, the then very low bandwidth of private internet con­nec­tions, not-to-mention the limited computing power of PCs at the time, the pro­gram­ming language finally ex­per­i­enced its break­through at the end of the 1990s. At the beginning stages of the World Wide Web Java applets were popular – these are ap­plic­a­tions written in Java that can be run using ap­pro­pri­ate runtime en­vir­on­ments in the browser and can interact with the user without having to send data to the server. Due to their resource de­pend­ency they weren’t very practical. With the in­tro­duc­tion of mobile devices that don’t support browser applets, the in­ter­act­ive web elements have com­pletely dis­ap­peared from the scene.

While Java flopped re­l­at­ively quickly in the frontend, the pro­gram­ming language has become a staple on the server side where the ap­plic­a­tion scenarios vary quite a lot: From servlets for server-run applet coun­ter­parts to complex en­ter­prise solutions like mid­dle­ware, banking software, or large content man­age­ment systems, a wide variety of Java tech­no­lo­gies are more in demand than ever, budget allowing. Because of its ad­vant­ages in terms of cost and time, the PHP scripts language is used on about three-quarters of all websites. For web de­velopers who work with Java, Spring offers not only the required struc­tures but also a con­sid­er­able sim­pli­fic­a­tion of the work process. The ad­vant­ages of Java web de­vel­op­ment include, but aren’t limited to, platform in­de­pend­ence, the ability to integrate with en­ter­prise software and processes, and a clear structure.

Which projects are best suited to the Spring framework?

Spring is typically used as a light­weight framework for Java ap­plic­a­tions since almost no ad­just­ments to the source code are necessary to profit from its many ad­vant­ages. Among other things, there are sim­pli­fic­a­tions of the im­ple­ment­a­tion of trans­ac­tion man­age­ment, in­ter­faces, and database access. The ability to carry out un­com­plic­ated unit and in­teg­ra­tions tests is also a key reason for the pop­ular­ity of the Spring framework. But the central point is without a doubt the aban­don­ment of platform-specific and non-stand­ard­ised com­pon­ents, which makes Spring both highly portable and in­de­pend­ent of ap­plic­a­tion servers. For this reason, you can easily employ a meta-framework in which further external com­pon­ents or entire frame­works will be in­teg­rated. A typical ap­plic­a­tion example is the de­vel­op­ment of backends on the basis of Spring, which is then linked to a frontend pre­vi­ously created using a UI framework such as Twitter Bootstrap. Spring is par­tic­u­larly strong in the real­iz­a­tion of complex business ap­plic­a­tions. For companies, the Spring framework in addition to Java has been an excellent choice for years for im­ple­ment­ing the required tech­no­lo­gies. Unlike pure web frame­works – such as Strate’s Apache com­pet­it­or project – Spring is not limited to web ap­plic­a­tions, but also enables the de­vel­op­ment of native desktop solutions. For simple ap­plic­a­tions – whether online or offline – Spring (and Java) are less suitable, even if the im­ple­ment­a­tion of such projects is possible in principle.

The benefits of Spring: an overview

If you are preparing for the de­vel­op­ment of your next big project and are on the search for a suitable framework, you should consider using the Spring framework. Es­pe­cially if Java plays a role in your plans, then you can con­sid­er­ably simplify your work by using its flexible module col­lec­tion. This gives you a powerful basic structure that you hardly ever need to change and instead can focus your efforts entirely on de­vel­op­ing the actual business logic. In the official GitHub re­pos­it­ory you can download and try out the framework at any time. Here are the ad­vant­ages of the Java de­vel­op­ment en­vir­on­ment once again, listed for you clearly:

  • POJOs can be applied for extra logic
  • Finished basic framework that hardly needs to be modified
  • No ap­plic­a­tion server required
  • Enables unit and in­teg­ra­tion tests
  • MVC ar­chi­tec­ture
  • Aspect-oriented pro­gram­ming with AspectJ is possible
  • De­pend­ency injection (external de­pend­ency control)
  • Pro­gram­mat­ic trans­ac­tion man­age­ment
Go to Main Menu