spring 3.0中包含哪些maven依赖项? [英] Which maven dependencies to include for spring 3.0?

查看:94
本文介绍了spring 3.0中包含哪些maven依赖项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用Spring 3.0(和maven)来完成我的第一个项目。我在一些项目中一直使用Spring 2.5(和引导版本)。不过我有点困惑,我在pom.xml中定义的依赖关系是什么模块。我只想使用核心容器函数(bean,core,context,el)。



我习惯了这样做:

 <依赖关系> 
< groupId> org.springframework< / groupId>
< artifactId> spring< / artifactId>
< version> 2.5.6< / version>
< / dependency>

但现在我有点困惑,因为3.0版本没有完整的包装弹簧模块。我试过以下,但没有工作(一些类缺少)。

 < dependency> 
< groupId> org.springframework< / groupId>
< artifactId> spring-core< / artifactId>
< version> 3.0.0.RELEASE< / version>
< / dependency>
<依赖关系>
< groupId> org.springframework< / groupId>
< artifactId> spring-expression< / artifactId>
< version> 3.0.0.RELEASE< / version>
< / dependency>
<依赖关系>
< groupId> org.springframework< / groupId>
< artifactId> spring-beans< / artifactId>
< version> 3.0.0.RELEASE< / version>
< / dependency>
<依赖关系>
< groupId> org.springframework< / groupId>
< artifactId> spring-context< / artifactId>
< version> 3.0.0.RELEASE< / version>
< / dependency>

任何帮助将不胜感激!

解决方案

在Keith Donald详细介绍的 Spring Blog 上有一个非常好的帖子howto 使用Maven获取Spring 3 Aritfacts ,当你需要每个依赖关系时,会有详细的注释...

  ! - 共享版本号属性 - > 
<属性>
< org.springframework.version> 3.0.0.RELEASE< /org.springframework.version>
< / properties>
<! - 其他模块使用的核心实用程序。
如果您使用Spring实用程序API定义这一点
(org.springframework.core。* / org.springframework.util。*) - >
<依赖关系>
< groupId> org.springframework< / groupId>
< artifactId> spring-core< / artifactId>
< version> $ {org.springframework.version}< / version>
< / dependency>
<! - 表达式语言(取决于spring-core)
如果使用Spring Expression API
(org.springframework.expression。*) - >
<依赖关系>
< groupId> org.springframework< / groupId>
< artifactId> spring-expression< / artifactId>
< version> $ {org.springframework.version}< / version>
< / dependency>
<! - Bean Factory和JavaBeans实用程序(取决于spring-core)
如果使用Spring Bean API定义了这一点
(org.springframework.beans。*) - >
<依赖关系>
< groupId> org.springframework< / groupId>
< artifactId> spring-beans< / artifactId>
< version> $ {org.springframework.version}< / version>
< / dependency>
<! - 面向方面的编程(AOP)框架
(取决于spring-core,spring-beans)
如果使用Spring AOP API定义这个API
(org。 springframework.aop *) - >。
<依赖关系>
< groupId> org.springframework< / groupId>
< artifactId> spring-aop< / artifactId>
< version> $ {org.springframework.version}< / version>
< / dependency>
<! - 应用程序上下文
(取决于spring-core,spring-expression,spring-aop,spring-beans)
这是Spring的依赖注入容器的中心工件
并且通常总是被定义 - >
<依赖关系>
< groupId> org.springframework< / groupId>
< artifactId> spring-context< / artifactId>
< version> $ {org.springframework.version}< / version>
< / dependency>
<! - 各种应用程序上下文实用程序,包括EhCache,JavaMail,Quartz,
和Freemarker集成
如果您需要这些集成中的任何一个,&?
<依赖关系>
< groupId> org.springframework< / groupId>
< artifactId> spring-context-support< / artifactId>
< version> $ {org.springframework.version}< / version>
< / dependency>
<! - 事务管理抽象
(取决于spring-core,spring-beans,spring-aop,spring-context)
如果使用Spring Transactions或DAO异常层次结构定义
(org.springframework.transaction。* / org.springframework.dao。*) - >
<依赖关系>
< groupId> org.springframework< / groupId>
< artifactId> spring-tx< / artifactId>
< version> $ {org.springframework.version}< / version>
< / dependency>
<! - JDBC数据访问库
(取决于spring-core,spring-beans,spring-context,spring-tx)
如果您使用Spring的JdbcTemplate API $ b定义这个$ b(org.springframework.jdbc。*) - >
<依赖关系>
< groupId> org.springframework< / groupId>
< artifactId> spring-jdbc< / artifactId>
< version> $ {org.springframework.version}< / version>
< / dependency>
<! - 与Hibernate,JPA和iBatis的对象到关系映射(ORM)集成。
(取决于spring-core,spring-beans,spring-context,spring-tx)
如果需要ORM(org.springframework.orm。*) - >定义这个
<依赖关系>
< groupId> org.springframework< / groupId>
< artifactId> spring-orm< / artifactId>
< version> $ {org.springframework.version}< / version>
< / dependency>
<! - 与JAXB,JiBX,
Castor,XStream和XML Bean的对象到XML映射(OXM)抽象和集成。
(取决于spring-core,spring-beans,spring-context)
如果需要OXM(org.springframework.oxm。*)定义这个 - >
<依赖关系>
< groupId> org.springframework< / groupId>
< artifactId> spring-oxm< / artifactId>
< version> $ {org.springframework.version}< / version>
< / dependency>
<! - 适用于Servlet和
Portlet环境的Web应用程序开发实用程序
(取决于spring-core,spring-beans,spring-context)
定义此if您使用Spring MVC,或希望使用Struts,JSF或另一个
Web框架与Spring(org.springframework.web。*) - >
<依赖关系>
< groupId> org.springframework< / groupId>
< artifactId> spring-web< / artifactId>
< version> $ {org.springframework.version}< / version>
< / dependency>
<! - 用于Servlet环境的Spring MVC
(取决于spring-core,spring-beans,spring-context,spring-web)
如果将Spring MVC与Servlet容器如
Apache Tomcat(org.springframework.web.servlet。*) - >
<依赖关系>
< groupId> org.springframework< / groupId>
< artifactId> spring-webmvc< / artifactId>
< version> $ {org.springframework.version}< / version>
< / dependency>
<! - 用于Portlet环境的Spring MVC
(取决于spring-core,spring-beans,spring-context,spring-web)
如果将Spring MVC与Portlet Container
(org.springframework.web.portlet。*) - >
<依赖关系>
< groupId> org.springframework< / groupId>
< artifactId> spring-webmvc-portlet< / artifactId>
< version> $ {org.springframework.version}< / version>
< / dependency>
<! - 支持使用JUnit和TestNG
等工具测试Spring应用程序此工件通常始终以
集成测试框架和单元测试存根的测试范围定义 - >
<依赖关系>
< groupId> org.springframework< / groupId>
< artifactId> spring-test< / artifactId>
< version> $ {org.springframework.version}< / version>
< scope> test< / scope>
< / dependency>


I am trying to do my first project with Spring 3.0 (and maven). I have been using Spring 2.5 (and primer versions) in quite some projects. Nevertheless I am kinda confused, what modules I have to define as dependencies in my pom.xml. I just want to use the core container functions (beans, core, context, el).

I was used to do this:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring</artifactId>
    <version>2.5.6</version>
</dependency>

But now I am kinda confused, as there is no full packed spring module for version 3.0 anymore. I tried the following but it didnt work (some classes are missing).

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>3.0.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-expression</artifactId>
        <version>3.0.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>3.0.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>3.0.0.RELEASE</version>
    </dependency>

Any help would be appreciated!

解决方案

There was a really nice post on the Spring Blog from Keith Donald detailing howto Obtain Spring 3 Aritfacts with Maven, with comments detailing when you'd need each of the dependencies...

<!-- Shared version number properties -->
<properties>
    <org.springframework.version>3.0.0.RELEASE</org.springframework.version>
</properties>
<!-- Core utilities used by other modules.
    Define this if you use Spring Utility APIs 
    (org.springframework.core.*/org.springframework.util.*)-->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>${org.springframework.version}</version>
</dependency>
<!-- Expression Language (depends on spring-core)
    Define this if you use Spring Expression APIs 
    (org.springframework.expression.*)-->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-expression</artifactId>
    <version>${org.springframework.version}</version>
</dependency>
<!-- Bean Factory and JavaBeans utilities (depends on spring-core)
    Define this if you use Spring Bean APIs 
    (org.springframework.beans.*)-->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-beans</artifactId>
    <version>${org.springframework.version}</version>
</dependency>
<!-- Aspect Oriented Programming (AOP) Framework 
    (depends on spring-core, spring-beans)
    Define this if you use Spring AOP APIs 
    (org.springframework.aop.*)-->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-aop</artifactId>
    <version>${org.springframework.version}</version>
</dependency>
<!-- Application Context 
    (depends on spring-core, spring-expression, spring-aop, spring-beans)
    This is the central artifact for Spring's Dependency Injection Container
    and is generally always defined-->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>${org.springframework.version}</version>
</dependency>
<!-- Various Application Context utilities, including EhCache, JavaMail, Quartz, 
    and Freemarker integration
    Define this if you need any of these integrations-->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context-support</artifactId>
    <version>${org.springframework.version}</version>
</dependency>
<!-- Transaction Management Abstraction 
    (depends on spring-core, spring-beans, spring-aop, spring-context)
    Define this if you use Spring Transactions or DAO Exception Hierarchy
    (org.springframework.transaction.*/org.springframework.dao.*)-->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-tx</artifactId>
    <version>${org.springframework.version}</version>
</dependency>
<!-- JDBC Data Access Library 
    (depends on spring-core, spring-beans, spring-context, spring-tx)
    Define this if you use Spring's JdbcTemplate API 
    (org.springframework.jdbc.*)-->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-jdbc</artifactId>
    <version>${org.springframework.version}</version>
</dependency>
<!-- Object-to-Relation-Mapping (ORM) integration with Hibernate, JPA and iBatis.
    (depends on spring-core, spring-beans, spring-context, spring-tx)
    Define this if you need ORM (org.springframework.orm.*)-->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-orm</artifactId>
    <version>${org.springframework.version}</version>
</dependency>
<!-- Object-to-XML Mapping (OXM) abstraction and integration with JAXB, JiBX, 
    Castor, XStream, and XML Beans.
    (depends on spring-core, spring-beans, spring-context)
    Define this if you need OXM (org.springframework.oxm.*)-->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-oxm</artifactId>
    <version>${org.springframework.version}</version>
</dependency>
<!-- Web application development utilities applicable to both Servlet and 
    Portlet Environments 
    (depends on spring-core, spring-beans, spring-context)
    Define this if you use Spring MVC, or wish to use Struts, JSF, or another
    web framework with Spring (org.springframework.web.*)-->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>${org.springframework.version}</version>
</dependency>
<!-- Spring MVC for Servlet Environments 
    (depends on spring-core, spring-beans, spring-context, spring-web)
    Define this if you use Spring MVC with a Servlet Container such as 
    Apache Tomcat (org.springframework.web.servlet.*)-->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>${org.springframework.version}</version>
</dependency>
<!-- Spring MVC for Portlet Environments 
    (depends on spring-core, spring-beans, spring-context, spring-web)
    Define this if you use Spring MVC with a Portlet Container 
    (org.springframework.web.portlet.*)-->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc-portlet</artifactId>
    <version>${org.springframework.version}</version>
</dependency>
<!-- Support for testing Spring applications with tools such as JUnit and TestNG
    This artifact is generally always defined with a 'test' scope for the 
    integration testing framework and unit testing stubs-->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-test</artifactId>
    <version>${org.springframework.version}</version>
    <scope>test</scope>
</dependency>

这篇关于spring 3.0中包含哪些maven依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆