IBM®
跳转到主要内容
    中国 [选择]    使用条款
 
 
Select a scope: Search for:    
    首页    产品    服务与解决方案     支持与下载    个性化服务    

developerWorks 中国  >  WebSphere | Open source  >

为 WebSphere Application Server Community Edition 开发 Spring 应用程序: 第 1 部分:Spring MVC

使用 Spring MVC 框架开发和部署示例应用程序

developerWorks

级别: 中级

Sunil Patil (sunilpatil@in.ibm.com), 软件工程师, IBM 

2007 年 8 月 13 日

现在注册或者使用您的 IBM ID 和密码登录。

如果您参加 Java™ 社区中的各种活动,甚至仅浏览与 Java 相关的在线杂志或 Blog 站点,则可能会听说过 Spring Framework,该软件在过去几年中赢得了众多关注。现在,您有机会尝试一下了!本系列教程由几部分组成,向您介绍如何开发可以与 IBM® WebSphere® Application Server Community Edition(免费的轻量级 Java 2 Platform Enterprise Edition (J2EE) 应用服务器)一起使用的 Spring 应用程序。本部分向您介绍在开发 Spring 应用程序时供您使用的各种数据库连接管理选项。了解 Spring 自已的 DataSource 实现,如何使用开源连接池实现,以及如何通过 Spring 应用程序使用由 WebSphere Application Server Community Edition 维护的连接池。另外,您还将了解 Spring 如何让您方便地从一个连接池实现切换到另一个连接池实现,而无需在 Java 代码中进行任何更改。

目标

  • 学习如何开发可以与 IBM WebSphere Application Server Community Edition 一起使用的 Spring 应用程序。

  • 熟悉在开发 Spring 应用程序时供您使用的各种数据库连接管理选项

  • 了解 Spring 自已的 DataSource 实现,如何使用开源连接池实现,以及如何通过 Spring 应用程序使用由 WebSphere Application Server Community Edition 维护的连接池。

  • 了解 Spring 如何让您方便地从一个连接池实现切换到另一个连接池实现,而无需在 Java 代码中进行任何更改。

预备知识

要按照本教程中的说明进行操作,您应该对以下内容有基本的了解:

  • 面向对象的编程
  • Java EE 术语
  • XML 语义
  • JSP 标记、标记库和标记库描述符

本教程假设您是经验丰富的 Java EE 开发人员,并熟悉 Spring Framework 基础知识。另外,您还需要了解模型-视图-控制器 (MVC),但这不是必需的。尽管不需要高级知识,但是您应该熟悉如何使用 Spring BeanFactory 和 Spring AOP。(如果您是 Spring Framework 新手,则 Arun Chhatpar 在 developerWorks 上发表的“Apache Geronimo 和 Spring 框架系列教程”是获得入门知识的优秀作品。)


系统需求

您需要下载几个必要的应用程序,才能按照本教程的说明进行操作并使用示例代码,其中包括:

  • JDK 1.4.2——WebSphere Application Server Community Edition 目前使用 Sun Microsystems 实现 Remote Method Invocation (RMI) 的 Object Request Broker (ORB),所以需要 Sun 的 JDK。在本教程中,您将使用 JDK 1.4.2 来测试示例代码。
  • WebSphere Application Server Community Edition——本文中的示例代码是使用版本 1.1 测试的。如果您决定使用其他版本的 WebSphere Application Server Community Edition,则可能必须在 geronimo-web.xml 文件中进行某些更改。
  • Spring Framework——将压缩文件与所有依赖项一起使用。注意:如果您没有下载带所有依赖项的 Spring 版本,那么必须手动下载其他必需的 JAR 文件。开发本文中的示例代码时,使用的是 Spring Framework 2.0 版。
  • Eclipse Web Tools Platform (WTP) 1.0.1——此开源项目为创建 servlets、JavaServer Pages (JSP) 组件和 Enterprise JavaBeans (EJB) 提供了方便您使用的向导,从而使 Java EE 开发变得更简单。它还为 JSP 和 XML 提供编辑器。请浏览参考资料部分,获得更多关于如何使用此工具的信息。
  • WebSphere Application Server Community Edition server adapter(以前称为 WebSphere Application Server Community Edition 的 Eclipse 插件)——此服务器适配器允许您在 Eclipse 内部与 WebSphere Application Server Community Edition 交互。您可以执行一些操作,如启动或停止服务器,或以正常或调试模式进行启动。服务器适配器还允许您在服务器上运行或调试项目,只需右键单击一个项目并选择 Run on ServerDebug on Server即可。我认为此适配器解决了开源项目中的一个最大难题,这是其他开发工具不能解决的。

建议您将 Eclipse Web Tools Platform 与 WebSphere Application Server Community Edition 的 Eclipse 插件结合使用,并将其作为您的开发环境,但这不是必需的。您可以选用另一个编辑器。如果使用其他编辑器,您可以使用本示例附带的 Ant 构建脚本来构建源代码。

共享此教程

digg Digg this story
del.icio.us Post to del.icio.us
Slashdot Slashdot it!



学习时间

少于 2 小时


格式

html




回页首


IBM 公司保留在 developerWorks 网站上发表的内容的著作权。未经IBM公司或原始作者的书面明确许可,请勿转载。如果您希望转载,请通过 提交转载请求表单 联系我们的编辑团队。

文档选项

未显示需要 JavaScript 的文档选项


本系列的更多信息:
为 WebSphere Application Server Community Edition 开发 Spring 应用程序

    关于 IBM 隐私条约 联系 IBM 使用条款