快速搭建ssh框架

1、Spring

  右键→MyEclipse→Add Spring Capabilities   弹出提示框

  选择:  Spring 2.0

  添加Liarbaries:

    Spring 2.0 AOP Libraries

    Spring 2.0 Core Libraries

    Spring 2.0 Web Libraries

→Next→Finish

 

2、Hibernate

  右键→MyEclipse→Add Hibernate Capabilities   弹出提示框

  选择:Hibernate 3.1

  选择Libraries:

    Hibernate 3.1 Core Libraries

    Spring 2.0 Persistence Core Libraries

Next→

  选择Spring configuration file(applicationContext.xml)   意为使用spring的配置文件

Next→

  选择Existing Spring configuration file

  配置SessionFactory ID:  如 : ypSessionFactory

Next→

  配置DataSource的Bean Id  :  如:  ypDataSource

  选择DB Driver

Next→

  Create SessionFactory class意为询问是否需要创建一个SessionFactory的类

  不勾选,我们不需要

 

 

到这里applicationContext.xml会报一个Class"org.apache.commons.BasicDataSource"not found的错

这是因为spring和hibernate整合需要的jar还没有导入

解决方法:

  右键→Build Path→Configure Build Path弹出提示框

  点击Add Library弹出提示框

  选择MyEclipse Libraries

Next→

  选择:Spring 2.0 ORM/DAO/Hibernate3 Libraries

  这时你会发现OK按钮无法点击了

  原因是Spring 2.0 ORM/DAO/Hibernate3 Libraries和Spring 2.0 Persistence Core Libraries冲突了

  所以之前添加Hibernate的时候还是不要勾选Spring 2.0 Persistence Core Libraries

  Remove掉Spring 2.0 Persistence Core Libraries后就可以点击OK了

 

3、Struts

  导入struts常用包

  配置struts.xml和struts.properties文件

4、除了上述的jar包外还需要另外两个jar

  commons-pool.jar

  struts2-spring-plugin-2.16.jar

5、配置web.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
 xmlns="
http://java.sun.com/xml/ns/javaee"
 xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
  <context-param>
   <param-name>contextConfigLocation</param-name>
   <param-value>/WEB-INF/classes/applicationContext.xml</param-value>
  </context-param>
  <filter>
   <filter-name>struts</filter-name>
   <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
  </filter>
  <filter-mapping>
   <filter-name>struts</filter-name>
   <url-pattern>/*</url-pattern>
  </filter-mapping>
  <listener>
   <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
</web-app>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值