SSM配置
<?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:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
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.1.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">
<!-- 读取properties配置文件 -->
<context:property-placeholder location="classpath:jdbc.properties"/>
<!--(使用dbcp连接池)
destroy-method:銷毀的方法
scope:一個連接池,要保持單例的模式
-->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close"
scope="singleton">
<property name="driverClassName" value="${driver}"/>
<property name="url" value="${url}"/>
<property name="username" value="${uname}"/> <!--value值不是username-->
<property name="password" value="${password}"/>
</bean>
<!-- 让事务的注解起效 -->
<tx:annotation-driven/>
<!-- 事务管理 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<!-- 配置mybatis的 sqlSessionFactory -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation" value="classpath:mybatis-configuration.xml" />
</bean>
<!-- Mapper接口所在包名,Spring会自动查找其下的Mapper -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.prj.dao" />
</bean>
</beans>
一、编辑jdbc.properties文件
二、mybatis的配置
a.配置实体类的 包名
三、spring mvc的配置
a.自动扫描注解
b.视图解析器
四、spring的配置文件
a.读取properties配置文件
b.配置数据源
c.配置事务
d.配置mybatis的 sqlSessionFactory
e.配置数据访问层,接口和映射配置。
五、web.xml
a.加载spring的相关配置文件
b.加载spring mvc的相关配置文件
c.配置spring的监听器
d.配置字符编码
注意事项(和以前写法不同的地方)
a.业务逻辑层的实现类要添加@Service注解,
并且业务逻辑层的实现类下的数据访问层的属性要添加@Resource注解
这样的话不用去new,也不用去依赖注入
b.在控制层中业务逻辑层的属性要添加@Resource注解
SSM配置的更多相关文章
- java -- SSM配置完成后,能访问jsp文件不能访问html文件,报错解析
SSM配置完成后,能访问jsp文件不能访问html文件,报错解析 在确保路径没有任何问题的,情况下,相同的页面,jsp能够正常访问,html却不能正常访问(404). 解决方法: 在web.xml中添 ...
- 简单SSM配置详解
SSM:spring+springMVC+Mybatis 学习网友的http://www.cnblogs.com/invban/p/5133257.html,并对其进行了详细的解说. 源码下载:htt ...
- 4.SSM配置shiro权限管理
作者QQ:1095737364 QQ群:123300273 欢迎加入! 1.搭建SSM项目: http://www.cnblogs.com/yysbolg/p/6909021.html ...
- SSM配置梳理
这两天梳理了一下 SSM 的配置,做一个小总结 可能有一些不对的地方,如果您发现了什么错误,非常希望能帮忙指出,谢谢 我参考了很多文章,都标明了来源(链接),可能会影响阅读的连贯性,抱歉 ...
- mybatisplus ssm配置要点
本以为不难,但也捣鼓了大半天,记录要点如下: 在pom中引入mybatis plus相关包 <!-- mybatis-plus框架包 start --> <dependency> ...
- 校园电商项目3(基于SSM)——配置Maven
步骤一:添加必要文件夹 先在src/main/resources下添加两个文件夹 接着在webapp文件夹下添加一个resources文件夹存放我们的静态网页内容 WEB-INF里的文件是不会被客户端 ...
- ssm 配置多个数据源
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...
- SSM配置JDBC错误: cquisition Attempt Failed!!!
异常: 警告: com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@20ffa401 -- Acquisition Attempt Fa ...
- ssm 配置事务回滚
参考:https://blog.csdn.net/Mint6/article/details/78363761 在 applicationContext.xml 中配置好了事务和数据源等必须要用到的配 ...
随机推荐
- hibernate4.0+版本和3.0+版本的区别总结
自己总结下hibernate4.1版本中的新特性和hibernate3.3做区别 1.数据库方言设置 <property name=”dialect”>org.hibernate.dial ...
- (Step by Step)How to setup IP Phone Server(VoIP Server) for free.
You must have heard about IP Phone and SIP (Software IP Phone).Nowadays standard PSTN phone are bein ...
- 中局域网LAN中建立局域网可访问的类GitHub的服务器
There are several ways to do this Host internal repositories like Gitlab (free software) or Stash. T ...
- vmware 8下ubuntu 13.04安装vmware tools
在虚拟机vmware 8.0里安装了ubuntu 13.04.为了方便与主机交互,安装vmware tools. 解压后直接运行 ./vmware-install.pl 一路默认路径安装下来,到&qu ...
- 问题-Delphi编译到最后Linking时总是出现与ntdll.dll有关的错误还有Fatal Error Out of memory错误
1.跳出错误法 ===================================================在主界面的implementation {$R *.dfm} 下放入以下代码: ...
- [深入浅出Cocoa]详解键值观察(KVO)及其实现机理
一,前言 Objective-C 中的键(key)-值(value)观察(KVO)并不是什么新鲜事物,它来源于设计模式中的观察者模式,其基本思想就是: 一个目标对象管理所有依赖于它的观察者对象,并在它 ...
- Visual C++ 2012/2013的内存溢出检測工具
在过去,每次编写C/C++程序的时候,VLD差点儿是我的标配.有了它,就能够放心地敲代码,随时发现内存溢出. VLD最高可支持到Visual Studio 2012.不知道以后会不会支持Visual ...
- 【16】成对使用new和delete时要采取相同形式
简而言之,new时不带[],delete时也不带[]:new时带[],delete时也要带[].如果不匹配,要么造成多销毁对象,导致未定义行为:要么导致少销毁对象,导致内存泄漏.
- [置顶] Ubuntu 12.04中文输入法的安装
Ubuntu 12.04中文输入法的安装 Ubuntu上的输入法主要有小小输入平台(支持拼音/二笔/五笔等),Fcitx,Ibus,Scim等.其中Scim和Ibus是输入法框架. 在Ubuntu的中 ...
- VS2005配置CPPUnit进行单元測试
一. 编译CPPUnitproject 1. 解压文件cppunit-1.12.1.tar.gz. 2. 编译$BASE/src/cppunit/CppUnitLibraries.dsw中的cpp ...