Minimum JARs for Spring 3.0 dependency injection

前端 未结 3 1544
无人共我
无人共我 2021-02-08 01:47

Similarly to this question regarding an earlier Spring version, what are the minimum dependencies required for an application to use Spring 3.0 dependency injec

相关标签:
3条回答
  • 2021-02-08 02:48

    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
    0 讨论(0)
  • 2021-02-08 02:49

    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.

    0 讨论(0)
  • 2021-02-08 02:50

    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 讨论(0)
提交回复
热议问题