Struts2+Hibernate4+Spring3 整合登录例子
来源:互联网 发布:淘宝女士丝巾 编辑:程序博客网 时间:2024/05/01 10:57
IDE:MyEclipse2014
首先,通过MyEclipse自动依次生成struts,spring,hibernate(生成方法请看我之前的文章).
生成完成后,修改web.xml下的
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml,classpath:applicationContext-beans.xml</param-value>
</context-param>
红字部分为增加的配置文件路径.
完整目录结构:
接下来,把applicationContext.xml复制一份,改名为applicationContext-beans.xml用于存放工程中所有的bean的配置信息.
然后在applicationContext.xml中添加
<context:component-scan base-package="glut"></context:component-scan><aop:aspectj-autoproxy proxy-target-class="true"></aop:aspectj-autoproxy>完整代码:
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"xmlns:aop="http://www.springframework.org/schema/aop"xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsdhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd"><bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"><property name="url" value="jdbc:mysql://localhost:3306/test"></property><property name="driverClassName" value="com.mysql.jdbc.Driver"></property><property name="username" value="user"></property><property name="password" value="1234"></property></bean><bean id="sessionFactory"class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"><property name="dataSource"><ref bean="dataSource" /></property><property name="hibernateProperties"><props><prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop></props></property><property name="annotatedClasses"><list><value>glut.bean.User</value></list></property></bean><bean id="transactionManager"class="org.springframework.orm.hibernate4.HibernateTransactionManager"><property name="sessionFactory" ref="sessionFactory" /></bean><tx:annotation-driven transaction-manager="transactionManager" /><context:component-scan base-package="glut"></context:component-scan><aop:aspectj-autoproxy proxy-target-class="true"></aop:aspectj-autoproxy></beans>
完整代码下载
0 0
- Struts2+Hibernate4+Spring3 整合登录例子
- struts2+spring3+hibernate4整合
- spring3+Hibernate4+struts2整合
- ssh整合例子(spring3 + struts2 + hibernate4+dwr+ext+json)
- spring3.1+struts2+hibernate4整合
- Struts2+Spring3+Hibernate4+Maven整合
- struts2 spring3 hibernate4 最简单整合
- struts2 spring3 hibernate4 最简单整合
- 整合Struts2.3.12+hibernate4.2.0+spring3.2.2
- struts2+spring3+hibernate4+easyui+maven整合
- Struts2+Spring3+Hibernate4整合之Spring配置文件
- 使用maven整合struts2+hibernate4+spring3
- struts2.3+spring3.2+hibernate4.2例子
- Spring3.1 + Hibernate4.2.1 + JBPM5.4 + Ehache整合例子
- hibernate4 spring3 整合
- hibernate4 spring3 整合
- Spring3整合Hibernate4
- spring3、hibernate4、JPA整合
- MySQL 中的常用函数
- Java屏幕截图
- vi命令应用
- Java作业整理
- 自定义返回按钮
- Struts2+Hibernate4+Spring3 整合登录例子
- Spring MVC "The request sent by the client was syntactically incorrect ()"解决办法
- ztree点击事件加载树
- 百度地图主动定位功能
- swift 的关健词
- IOS8 旋转的问题
- 学习ASP.NET MVC5框架揭秘笔记-ASP.NET MVC路由(五)
- OpenWrt配置opkg.conf
- 谈科目三考试