开发者

Minimum JARs for Spring 3.0 dependency injection

开发者 https://www.devze.com 2023-01-22 08:38 出处:网络
Similarly to this question regarding an earlier Spring version, what are the minimum dependencies required for an a开发者_高级运维pplication to use Spring 3.0 dependency injection only?The application

Similarly to this question regarding an earlier Spring version, what are the minimum dependencies required for an a开发者_高级运维pplication to use Spring 3.0 dependency injection only? The application context will be configured by XML only. Spring depends on a logging framework, so assume I already include these JARs for logging:

  • jcl-over-slf4j.jar
  • logback-classic.jar
  • logback-core.jar
  • slf4j-api.jar


As stated in another answer, maven is the true path. If; however, you choose to stray, then based on section "1.2.1 Core Container" of the Spring Reference I believe these to be the minimum jars for core spring functionality:

  • org.springframework.asm-3.0.4.RELEASE.jar
  • org.springframework.beans-3.0.4.RELEASE.jar
  • org.springframework.context-3.0.4.RELEASE.jar
  • org.springframework.core-3.0.4.RELEASE.jar
  • org.springframework.expression-3.0.4.RELEASE.jar

Edited: sorted the list, using wiki formatting.

Updated for Spring 3.2: It seems that asm is not part of the 3.2 distribution. Below is the list for Spring 3.2:

  • spring-beans-3.2.0.RELEASE.jar
  • spring-context-3.2.0.RELEASE.jar
  • spring-core-3.2.0.RELEASE.jar
  • spring-expression-3.2.0.RELEASE.jar


the best - and reliable way - of establishing this is to create a maven project and add dependency for spring-core, spring-bundle and spring-context. when you build/install this project maven will do the needful.


YMMV, but I'd do the following:

First, import the Spring BOM in the dependency management section, to ensure a baseline dependency version:

<properties>
    <spring.version>3.2.6.RELEASE</spring.version>
</properties>
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-framework-bom</artifactId>
            <version>${spring.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
     </dependencies>
 </dependencyManagement>

Then, in the build/dependency section, import beans, context and core, and EL if you plan to configure Spring via xml configuration (or using test scope if you only plan to use Spring xml configuration for your tests harness.)

Note: This example is with 3.2.x. If you need to use Spring before 3.2.x, you will need to include asm explicitly. One possibility is to use a profile activated only for Spring versions below 3.2.x.

<build>
    <dependencies>
       <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <!-- inlines asm since 3.2.x -->
       </dependency>
       <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
       </dependency>
       <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
       </dependency>
       <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-expression</artifactId>
            <scope>test</scope><!-- or compile/provided if used beyond testing -->
       </dependency>
    </dependencies>
</build>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号