Analyzing Spring Dependencies

Spring has over 60 separate dependencies, all of which are available as part of the full Spring download. If you are building Spring from source, then you are going to need all of these dependencies. However, at runtime, most likely you will require only a subset of the dependencies and you can really minimize the size of your distribution by including only the necessary dependencies.

Due to the large number of dependencies, Spring groups them together to make working with them easier. These groups are represented as subdirectories of the main lib directory in the root of the distribution. Table 2-2 describes these groups along with a list of the JAR files in each group and a discussion of what the dependencies are used for.

Table 2-2: Spring Dependencies

Dependency Group

JAR Files



ant.jar, ant-junit.jar, ant-launcher.jar

Spring uses Apache Ant as its build tool and also for many other tasks such as documentation generation and test running. Ant is not used at all at runtime so you do not need to include this JAR file in your distribution.



The AOP Alliance ( is a combined, open source collaboration between many projects to provide a standard set of interfaces for AOP in Java. Spring's AOP implementation is based on the standard AOP Alliance APIs. You only need this JAR file if you plan to use any of Spring's AOP or AOP-based features.


axis.jar, saaj.jar, wsdl4j.jar

Spring uses the Apache Axis project to support the JAXRPC capabilities in Spring remoting. You only need these files if you are using JAXRPC Remoting.


burlap-2.1.12.jar, hessian-2.1.12.jar

Spring remoting provides support for a wide variety of different protocols, including Caucho's Burlap and Hessian. You only need the JARs in this group if you are using the corresponding protocols in your application.



CGLIB is used to generate dynamic proxy classes for use in both the core DI and AOP implementations. You almost always need to include CGLIB with your application, because it is used to implement a wide range of Spring's functionality.



COS stands for com.oreilly.servlet, which is a collection of useful classes for working with Servlets and web-based applications. Spring uses COS in two areas: for handling file uploads and for sending e-mail. In both cases, COS is just an implementation choice, so you only need to include cos.jar if you choose to use COS over one of the other implementations.



You must have dom4j when you are using Hibernate, so you need to include this JAR file if you plan to use Hibernate for ORM in your application.


easymock.jar, easymockclassextension.jar

EasyMock is used in the Spring test suite, so you only need to use this JAR for building and running the test suite; you do not need to distribute this with your application.



Spring provides wrapper classes around the FreeMarker templating engine and also provides support for using FreeMarker templates as views for your web applications. This is required whenever you are using FreeMarker.


ehcache.jar, hibernate2.jar, odmg.jar

These JAR files are required when you are using Spring's Hibernate integration and support classes. If you are using a different ORM tool, such as iBATIS, you can leave these JARs out of your application. When you are using Hibernate, you must also include the CGLIB JAR file in your application.



The hsqldb.jar file is used by the Spring sample applications.


ibatis-common.jar , ibatis-sqlmap.jar, ibatis-sqlmap-2.jar

These files are required when you are using Spring's iBATIS integration classes, but you can leave them out of your application if you are using JDBC or another ORM tool such as Hibernate or JDO.



Spring uses iText to provide PDF support in the web tier. Only include this JAR if your web applications need to generate PDF output.


activation.jar, connector-api.jar, ejb.jar, jaxrpc.jar, jdbc2_0-stdext.jar, jms.jar, jstl.jar, jta.jar, mail.jar, servlet.jar, xml-apis.jar

As you can see, there is a large array of different J2EE-related JAR files. You need the activation.jar and mail.jar files if you want to use the JavaMail implementation of Spring's mail support. You need connector-api.jar to use the JCA Connector for Hibernate, ejb.jar to use Spring's EJB support, and jms.jar for Spring's JMS support. For web appli- cations, you need servlet.jar and jstl.jar if you want to use Spring's JSTL support. The jaxrpc.jar file is required for JAXRPC support in Spring remoting and jta.jar is used for JTA transaction support. The remaining two jars, jdbc2_0-stdext.jar and xml-apis.jar, are needed for JDBC and XML configuration support respectively—but only when you are using a 1.3 JVM.


jakarta-commons commons-attributes-api.jar, commons-attributes-compiler.jar, commons-beanutils.jar, commons-collections.jar, commons-dbcp.jar, commons-digester.jar, commons-discovery.jar, commons-fileupload.jar, commons-lang.jar, commons-logging.jar, commons-pool.jar, commons- validator.jar

Many of the components from the Jakarta Commons project are used by Spring. You need the commons- attribute-api.jar if you want to use source level metadata in your application, plus you need the compiler JAR file to compile the attributes into your application. The BeanUtils, Collections, Digester, Discovery, and Validator JAR files are used by Struts, and Hibernate uses Collections as well. DBCP is used by Spring's JDBC support when you are using DBCP connection pools, and Pooling is required by some of the sample applications. FileUpload is required if you want to use the corresponding Spring wrapper to handle file uploads in your web applications. Finally, Logging is used throughout Spring, so you need to include it in every Spring- based application.



This is the Jakarta JSTL implementation and it is used by some of the Spring sample applications.



This is required when you are using Spring's JDBC classes in an application running on the JBoss application server.



This is required for Spring's JDO support.



JDOM is required when you are using iBATIS 1.3 with Spring. The version of iBATIS covered in this chapter is 2.0.


jotm.jar, xapool.jar

The jotm.jar file is required is you plan to use JOTM in conjunction with Spring's transaction abstraction layer. You only need xapool.jar if you plan to use XAPool for connection pooling in your application.



JUnit is not required at all at runtime; it is only used for building and running the test suite.



This is required when you want to use Spring to configure log4j logging.



This adds support for Microsoft Excel output to Spring's MVC framework.



This is used for Spring Quartz-based scheduling support.



This is required when you are using regular expressions to specify pointcuts in AOP. You can find more details on this in Chapter 6.



The Struts JAR is required whenever you want to use Struts in conjunction with Spring to build a web application.


velocity-1.4.jar, velocity-tools-generic-1.1.jar

Spring provides wrapper classes around Velocity to DI-enable it and also to reduce the amount of code you need to write to use Velocity in your application. In addition to this, Spring provides classes to support the use of Velocity as the view provider in the web tier. If you are using any of these features, you need to include the Velocity JAR files in your distribution.



Commons Attributes uses this to parse your source code files and extract the attribute information. Include this JAR file if you are using Spring's Commons Attributes support.

As you can see, Spring's dependencies are quite varied, and for most applications, you only need a fraction of the full dependency set. It is worthwhile spending the time to pick out exactly what dependencies you need and only adding those to your application. In this way, you can keep the size of your application down; this is a particular benefit to those of you who frequently need to deploy to remote locations. Keeping the size of your application as small as possible is especially important if you plan to distribute your application over the Web to people who may be downloading over a slow link.

Pro Spring
Pro Spring
ISBN: 1590594614
EAN: 2147483647
Year: 2006
Pages: 189

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: