java Spring 3.0 依赖注入的最小 JAR
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4053981/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Minimum JARs for Spring 3.0 dependency injection
提问by Chin Huang
Similarly to this question regarding an earlier Spring version, what are the minimum dependencies required for an application to use Spring 3.0dependency 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:
与有关早期 Spring 版本的这个问题类似,应用程序仅使用 Spring 3.0依赖项注入所需的最低依赖项是什么?应用程序上下文将仅由 XML 配置。Spring 依赖于一个日志框架,所以假设我已经包含了这些用于日志记录的 JAR:
- jcl-over-slf4j.jar
- logback-classic.jar
- logback-core.jar
- slf4j-api.jar
- jcl-over-slf4j.jar
- logback-classic.jar
- logback-core.jar
- slf4j-api.jar
回答by DwB
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 ReferenceI believe these to be the minimum jars for core spring functionality:
正如另一个答案中所述,maven 是真正的路径。如果; 但是,您选择流浪,然后根据Spring Reference 的“1.2.1 Core Container”部分, 我相信这些是核心 spring 功能的最少 jars:
- 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
- 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.
编辑:使用 wiki 格式对列表进行排序。
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 3.2 更新:似乎 asm 不是 3.2 发行版的一部分。以下是 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
- 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
回答by anirvan
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.
建立这一点的最佳且可靠的方法是创建一个 maven 项目并添加对 spring-core、spring-bundle 和 spring-context 的依赖。当您构建/安装此项目时,maven 将完成所需的工作。
回答by luis.espinal
YMMV, but I'd do the following:
YMMV,但我会做以下事情:
First, import the Spring BOM in the dependency management section, to ensure a baseline dependency version:
首先在依赖管理部分导入Spring BOM,保证一个基线依赖版本:
<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.)
然后,在构建/依赖项部分,如果您计划通过 xml 配置来配置 Spring(或者如果您只计划为您的测试工具使用 Spring xml 配置,则使用测试范围)导入 bean、上下文和核心以及 EL。
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.
注意:此示例使用 3.2.x。如果您需要在 3.2.x 之前使用 Spring,则需要显式包含 asm。一种可能性是使用仅为低于 3.2.x 的 Spring 版本激活的配置文件。
<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>