SpringMVC + hibernate 配置文件
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1"> <servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet> <servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping> <context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param> <listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>
applicationContext.xml
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd"
default-init-method="init" default-destroy-method="destroy"> <!-- 导入外部的properties文件 -->
<context:property-placeholder location="classpath:jdbc.properties"/>
<!--<context:annotation-config/>--><!--启用注解扫描--> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"><!--数据源-->
<property name="url" value="${jdbc.url}"/>
<property name="driverClassName" value="${jdbc.driver}"/>
<property name="username" value="${jdbc.name}"/>
<property name="password" value="${jdbc.pass}"/>
</bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>hbm/User.hbm.xml</value>
<value>hbm/UserDetails.hbm.xml</value>
<value>hbm/Goods.hbm.xml</value>
<value>hbm/GoodDetails.hbm.xml</value>
<value>hbm/BuyCar.hbm.xml</value>
<value>hbm/Order.hbm.xml</value>
<value>hbm/OrderDetails.hbm.xml</value>
</list>
</property>
</bean> <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean> <tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="create*"/>
<tx:method name="query*"/>
<tx:method name="update*"/>
<tx:method name="delete*"/>
</tx:attributes>
</tx:advice> <aop:config>
<!--切面的配置 id表示切面的唯一id,ref表示切面的支持类-->
<aop:pointcut id="CRUDOperate" expression="execution(* com.iotek.homework.service.*.*(..))"/><!--切点( 切入点)-->
<aop:advisor advice-ref="txAdvice" pointcut-ref="CRUDOperate"/>
</aop:config> <bean id="hibernateTemplate" class="org.springframework.orm.hibernate4.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory"/>
</bean> <!--user start-->
<bean id="userDAO" class="com.iotek.homework.dao.UserDAOImpl"/>
<bean id="userService" class="com.iotek.homework.service.UserServiceImpl"/>
<bean id="userController" class="com.iotek.homework.controller.UserController"/>
<!--user end--> <!--userDetails start-->
<bean id="userDetailsDAO" class="com.iotek.homework.dao.UserDetailsDAOImpl"/>
<bean id="userDetailsService" class="com.iotek.homework.service.UserDetailsServiceImpl"/>
<!-- <bean id="userDetailsAction" class="com.iotek.homework.actions.UserDetailsAction"/>-->
<!--userDetails end--> <!--goods start-->
<bean id="goodsDAO" class="com.iotek.homework.dao.GoodsDAOImpl"/>
<bean id="goodsService" class="com.iotek.homework.service.GoodsServiceImpl"/>
<!-- <bean id="goodsAction" class="com.iotek.homework.actions.GoodsAction"/>-->
<!--goods end--> <!--buyCar start-->
<bean id="buyCarDAO" class="com.iotek.homework.dao.BuyCarDAOImpl"/>
<bean id="buyCarService" class="com.iotek.homework.service.BuyCarServiceImpl"/>
<!-- <bean id="buyCarAction" class="com.iotek.homework.actions.BuyCarAction"/>-->
<!--buyCar end--> <!--orders start-->
<bean id="ordersDAO" class="com.iotek.homework.dao.OrdersDAOImpl"/>
<bean id="ordersService" class="com.iotek.homework.service.OrdersServiceImpl"/>
<!-- <bean id="ordersAction" class="com.iotek.homework.actions.OrdersAction"/>-->
<!--orders end--> </beans>
dispatcher-servlet.xml
<?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:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd"> <!-- 支持注解 -->
<mvc:annotation-driven />
<!--注解扫描-->
<context:component-scan base-package="com.iotek.homework.controller"/> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/pages/"/>
<property name="suffix" value=".jsp"/>
</bean> <bean id="jsonConvert" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"/> <bean id="stringConvert" class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/plain;charset=UTF-8</value>
</list>
</property>
</bean> <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="jsonConvert"/>
<ref bean="stringConvert"/>
</list>
</property>
</bean> <import resource="classpath:applicationContext.xml"/> <!--静态资源注册-->
<mvc:resources mapping="/css/*" location="/css/"/>
<mvc:resources mapping="/js/*" location="/js/"/>
<mvc:resources mapping="/images/*" location="/images/"/>
</beans>
SpringMVC + hibernate 配置文件的更多相关文章
- Maven搭建SpringMVC+Hibernate项目详解 【转】
前言 今天复习一下SpringMVC+Hibernate的搭建,本来想着将Spring-Security权限控制框架也映入其中的,但是发现内容太多了,Spring-Security的就留在下一篇吧,这 ...
- springmvc+hibernate入门-揭开神秘的面纱
Spring 框架提供了构建 Web 应用程序的全功能 MVC 模块.使用 Spring 可插入的 MVC 架构,可以选择是使用内置的 Spring Web 框架还是 Struts 这 ...
- Maven搭建SpringMVC+Hibernate项目详解
前言 今天复习一下SpringMVC+Hibernate的搭建,本来想着将Spring-Security权限控制框架也映入其中的,但是发现内容太多了,Spring-Security的就留在下一篇吧,这 ...
- springMVC用法 以及一个简单的基于springMVC hibernate spring的配置
替代struts 1 web.xml中配置springmvc中央控制器 <?xml version="1.0" encoding="UTF-8"?> ...
- Maven搭建SpringMVC+Hibernate项目详解(转)
前言 今天复习一下SpringMVC+Hibernate的搭建,本来想着将Spring-Security权限控制框架也映入其中的,但是发现内容太多了,Spring-Security的就留在下一篇吧,这 ...
- SpringMVC Hibernate+Spring+Spring MVC+Bootstrap的管理系统实现
SpringMVC学习系列(12) 完结篇 之 基于Hibernate+Spring+Spring MVC+Bootstrap的管理系统实现 到这里已经写到第12篇了,前11篇基本上把Spring M ...
- springMVC+Hibernate配置
本文描述下 sypro 项目中使用 springMVC+Hibernate配置,初学SpringMVC做下简单整理解. 1.web项目首先我们要使用 web.xml文件将 spring配置引入进来 & ...
- 框架篇:Spring+SpringMVC+hibernate整合开发
前言: 最近闲的蛋疼,搭个框架写成博客记录下来,拉通一下之前所学知识,顺带装一下逼. 话不多说,我们直接步入正题. 准备工作: 1/ IntelliJIDEA的安装配置:jdk/tomcat等..(本 ...
- springMvc+hibernate的web application的构建
闲来没事,想整理下一些知识. 这篇文章是关于spring的web程序的搭建,有什么不对的地方希望大家批评指正. 首先我们要了解什么是spring,这里可能很多大家也都明白,无非是一个管理对象的一个容器 ...
随机推荐
- C# 多线程系列(五)
死锁 为了线程安全,我们在需要的是会使用”独占锁“,但过多的锁定也会有麻烦.多个线程因为竞争资源相互等待而造成的僵局,我们称为死锁.若无外力作用,这些进程将都无法推进.在死锁中,至少有两个线程被挂起, ...
- Laravel (5.5.33) 加载过程(二)
本次说明代码 /* |-------------------------------------------------------------------------- | Turn On The ...
- HTML+CSS(12)
n CSS浮动和清除 Float:让元素浮动,取值:left(左浮动).right(右浮动). Clear:清除浮动,取值:left(清除左浮动).right(清除右浮动).both(同时清除上面的 ...
- JS——轮播图简单版
1.小图标版本 <!DOCTYPE html> <html lang="en"> <head> <meta charset="U ...
- linux杀掉某个进程的脚本
https://www.cnblogs.com/zeng1994/p/13a2c5a28e55dd3abc2c75a4fb80371a.html awk的说明: https://www.cnblogs ...
- 简述cookie ,localStrage,sessionStorage的区别?
1.cookie: 是一个回话跟踪技术,信息存储在用户硬盘,可以做全局变量. 什么是会话:用户进入网站,开始浏览到结束的这样的一个过程,称为一次会话. 会话跟踪技术:浏览器和服务器之间进行多次请求数据 ...
- Appium使用方法说明
global driver# 元素定位driver.find_element_by_id("id") # id定位driver.find_element_by_name(" ...
- [luogu4728 HNOI2009] 双递增序列 (dp)
传送门 Solution 前几天刚做了类似题,这种将一个序列拆分为两个单调序列的题一般都是设\(dp[i]\)表示i为一个单调序列的末尾时,另一个序列的末尾是多少 然后应用贪心的思想,在这道题中就是让 ...
- [luogu1485 HNOI2009] 有趣的数列 (组合数学 卡特兰数)
传送门 Solution 卡特兰数 排队问题的简单变化 答案为\(C_{2n}^n \pmod p\) 由于没有逆元,只好用分解质因数,易证可以整除 Code //By Menteur_Hxy #in ...
- Shell脚本备份文件
使用crontab 定时备份文件 1. 编辑crontab规则 2. 编写shell脚本 cp -R "/data/www/code" "/home/backup/cod ...