문제

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
도움이 되었습니까?

해결책

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>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top