Minimum JARs for Spring 3.0 dependency injection

删除回忆录丶 提交于 2020-01-12 04:40:11

问题


Similarly to this question regarding an earlier Spring version, what are the minimum dependencies required for an application 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

回答1:


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



回答2:


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.




回答3:


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>


来源:https://stackoverflow.com/questions/4053981/minimum-jars-for-spring-3-0-dependency-injection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!