如何搭建SSH框架,myeclipse搭建SSH框架详解
2017-06-08 18:08
573 查看
1、先新建个Web项目
2 、添加struts2依赖包和配置文件
右击工程,选择“myeclipse”在二级菜单中找到“Add Struts Capabiliies” 点击进入3、添加spring框架依赖包和配置文件
右击工程,选择“myeclipse”在二级菜单中找到“Add Spring Capabiliies” 点击进入4、 新建“mysql-test”数据库连接
首先,打开“MyEclipse Database Explorer”视图,步骤:工具栏“Widow” ——》“Open Perspective”——》“Other”——》“MyEclipse Database Explorer” ——“OK”接着,在Myeclipse右上角找到切换视图的图标,切换到“MyEclipse Database Explorer”视图,在该视图上我们可以新建数据库连接,如下图
5、添加Hibernate框架依赖包和配置文件
右击工程,选择“myeclipse”在二级菜单中找到“Add Hibernate Capabiliies” 点击进入数据源选择步骤4新建的数据库连接“mysql-test”
6、通过“mysql-test”数据库连接,我们可以生成hibernate实体类和映射文件,以users表为例,如下图
效果如下图:
7、添加Spring事务管理
首先,修改applicationContext.xml文件,修改<beans>标签,将标签的属性修改成:<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">[/code]
接着,再添加以下内容:
<!--声明一个事务管理器 --> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory"> <ref local="sessionFactory" /> </property> </bean> <!-- 声明一个事务通知 --> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="*" propagation="REQUIRED"/> </tx:attributes> </tx:advice> <!-- 声明一个AOP切入点 --> <aop:config> <aop:pointcut id="daoMethods" expression="execution(* edu.dao.impl.*.*(..))" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="daoMethods"/> </aop:config>
相关文章推荐
- 如何在myeclipse里面搭建ssh框架
- SSH框架介绍以及如何搭建(myEclipse下)
- 【原创】用MyEclipse搭建和配置SSH框架详解(图文)
- SSH框架介绍以及如何搭建(myEclipse下)
- eclipse搭建SSH框架详解 .
- 图文详解如何搭建Windows的Android C++开发环境(一)
- 详解如何让MyEclipse具有强大的提示功能
- 详解如何搭建DHCP服务器 推荐
- eclipse搭建SSH框架详解
- MyEclipse搭建SSH框架 Struts2.1+Spring3.0+hibernate3.3
- 用MyEclipse搭建SSH框架 Struts2.1 Spring3.0 Hibernate3.3 搭建SSH框架
- 图文详解如何搭建Windows的Android C++开发环境(一)
- 详解在Myeclipse中搭建ssh工程(一)
- 如何在MyEclipse下集成SVN详解
- 用MyEclipse搭建SSH框架 Struts Spring Hibernate
- 详解如何让MyEclipse具有强大的提示功能
- 图文详解如何搭建Windows的Android C++开发环境(一)
- 图文详解如何搭建Windows的Android C++开发环境(一)
- 图文详解如何搭建Windows的Android C++开发环境(一)
- 用MyEclipse搭建SSH框架 Struts Spring Hibernate