Spring.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:p="http://www.springframework.org/schema/p" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd "> <mvc:annotation-driven/> <!--引入属性文件 --> <context:property-placeholder location="classpath:jdbc.properties" /> <!-- service和dao包(自动注入) --> <context:component-scan base-package="com.meng.service,com.meng.dao" /> </beans>
SpringMVC.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:p="http://www.springframework.org/schema/p" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd "> <mvc:annotation-driven /> <!-- 支持spring3.0新的mvc注解 --> <context:component-scan base-package="com.meng" /> <!-- 避免IE执行AJAX时,返回JSON出现下载文件 --> <bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"> <property name="supportedMediaTypes"> <list> <value>text/html;charset=UTF-8</value> </list> </property> </bean> <!-- 启动Spring MVC 的注解功能,完成请求和注解POJO的映射 --> <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> <property name="messageConverters"> <list> <ref bean="mappingJacksonHttpMessageConverter" /> <!-- json转换器 --> </list> </property> </bean> <!-- 页面View层基本信息设定 --> <bean id="viewResolver" p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /> </bean> <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <property name="defaultEncoding" value="UTF-8" /> <property name="maxUploadSize" value="32505856" /><!-- 上传文件大小限制为31M,31*1024*1024 --> <property name="maxInMemorySize" value="4096" /> </bean> </beans>
Spring-Mybatis.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:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd "> <!--开启注解支持 --> <mvc:annotation-driven/> <!--创建jdbc数据源 --> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${driver}" /> <property name="url" value="${url}" /> <property name="username" value="${username}" /> <property name="password" value="${password}" /> <!-- 初始化连接大小 --> <property name="initialSize" value="0" /> <!-- 连接池最大使用连接数量 --> <property name="maxActive" value="20" /> <!-- 连接池最大空闲 --> <property name="maxIdle" value="20" /> <!-- 连接池最小空闲 --> <property name="minIdle" value="0" /> <!-- 获取连接最大等待时间 --> <property name="maxWait" value="60000" /> </bean> <!-- mybatis文件 --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <!-- 自动扫描entity目录,省略Configuration.xml里手工配置 --> <property name="mapperLocations" value="classpath:com/meng/po/*.xml" /> </bean> <bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate"> <constructor-arg index="0" ref="sqlSessionFactory" /> </bean> <!-- 配置事务管理器 --> <bean name="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean> <!-- 注解方式配置事物 --> <tx:annotation-driven transaction-manager="transactionManager" /> <!-- 拦截器方式配置事物 --> <tx:advice id="transactionAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="save*" propagation="REQUIRED" /> <tx:method name="update*" propagation="REQUIRED" /> <tx:method name="insert*" propagation="REQUIRED" /> <tx:method name="delete*" propagation="REQUIRED" /> <tx:method name="find*" propagation="REQUIRED" read-only="true" /> <tx:method name="select*" propagation="REQUIRED" read-only="true" /> <tx:method name="search*" propagation="REQUIRED" read-only="true" /> <tx:method name="datagrid*" propagation="REQUIRED" read-only="true" /> <tx:method name="*" propagation="REQUIRED" /> </tx:attributes> </tx:advice> <aop:config> <!--定义在service包和所有子包里的任意类的任意方法的执行 --> <aop:pointcut id="transactionPointcut" expression="execution(* com.meng.service..*Impl.*(..))" /> <aop:advisor pointcut-ref="transactionPointcut" advice-ref="transactionAdvice" /> </aop:config> </beans>
运行环境:windows7+myeclipse 8.5+Tomcat 6.x
数据库:mysql
DEMO经过测试运行没问题,功能比较简单,只是进行整合练习,哪些地方不好大家可以提提意见
下载链接:http://pan.baidu.com/s/1mgkLABI
相关推荐
SpringMvc Spring Mybatis Maven 注解方式
报表后端采用技术: SpringBoot整合SSM(Spring+Mybatis-plus+ SpringMvc),spring security 全注解式的权限管理和JWT方式禁用Session,采用redis存储token及权限信息 报表前端采用Bootstrap框架,结合Jquery Ajax,...
shiro作为安全框架,主流技术 几乎零XML,极简配置 两套UI实现(bootstrap+layer ui),可以自由切换 报表后端采用技术: SpringBoot整合SSM(Spring+Mybatis-plus+ SpringMvc),spring security 全注解式的权限管理和...
由springMVC和mybatis整合而成的一个demo,使用了注解,有junit单元测试,我这里已经测试通过。sql文件已在压缩文件中,直接导入myeclipse中即可,不排除jdk版本过低可能导致的错误,我是在myeclipse2013上面编写的...
SpringMVC+MyBatis+MySql注解示例.。整合好的一个demo 可以下载来学习学习
SpringMVC+Mybatis整合及dao、service强封装:一、SPringMVC与Mybatis框架整合,其中SpringMVC主要采用注解方式实现,Mybatis采用xml为主,对数据库开发、测试、部署环境进行分离配置;二、在封装上针对Mybatis进行...
springMVC+Mybatis3 0 2+spring3 0 5(包含事务详解 代码诠释 含数据库文件) 注解实现自动注入 展示了增 删 改 查 注解 sql文件 经过严密测试绝对可以运行起来
1.Gradle+SpringBoot+SpringMVC+Mybatis+Jersey+Mybatis+MySQL项目整合实例(全注解实例) 2.包含word文档
这里就要导入mybatis和spring的整合包了,这里sqlsession中也要导入mybatis的配置文件 2.6 spring-bean 配置mapper自动扫描 MapperScannerConfigurer将扫描basePackage所指定的包下的所有接口类(包括子类), ...
更好的学习springMVC和mybatis
springMVC+Mybatis3 0 2+spring3 0 5(包含事务详解 代码诠释 含数据库文件) 注解实现自动注入 展示了增 删 改 查 注解 sql文件 经过严密测试绝对可以运行起来
本例子使用 SpringMVC + Mybatis 框架整合, 基于 Spring 注解实现, 省去了 Spring 繁琐的 bean 手工配置,实现的功能包括: 1、 用户登录、注销 2、 登录界面生成验证码图片 3、 用户表数据的增、删、改、查、分页...
其实 SSM 整合的实质,仅仅就是将 MyBatis整合入 Spring。因为 SpringMVC原本就是 Spring的一部分,不用专门整合。 SSM 整合的实现方式可分为两种:基于 XML 配置方式,基于注解方式。 整合过程:1、创建maven项目;...
shiro作为安全框架,主流技术 几乎零XML,极简配置 两套UI实现(bootstrap+layer ui),可以自由切换 报表后端采用技术: SpringBoot整合SSM(Spring+Mybatis-plus+ SpringMvc),spring security 全注解式的权限管理和...
springmvc+mybatis+ehcache+freemarker+sitemesh页面布局(注解)整合实例完美运行
本项目为ssm搭建而成的框架,采用restful风格及注解的形式而进行编写的,实现用户登录的功能。
springMVC+MyBatis+Ehcache项目整合 里面有几个调用的例子 还解决一般行整合出现 MyBatis事物无法回滚问题 Ehcache 以注解的方式进行整合 项目架构一般 不喜欢别骂我 没打算收你们的积分 不要问我叫什么 大家都叫我...
包括spring+springmvc+mybatis框架基础配置文件,对于基础学习ssm框架的童鞋来说,保存这个就好了,有注解一看就懂
springmvc和mybatis框架整合,Controller使用注解和非注解方式实现。