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 中配置好了事务和数据源等必须要用到的配 ...
随机推荐
- EGit插件安装(附Eclipse版本对应表)
最近eclipse添加egit插件,通过网上的方法下载安装后不显示git选项.通过官网了解到egit的版本对应相应的eclipse版本. 如果你安装了最新版本,需要先卸载重启eclipse后重新安装兼 ...
- Lua包管理工具Luarocks详解 - 15134559390的个人空间 - 开源中国社区
Lua包管理工具Luarocks详解 - 15134559390的个人空间 - 开源中国社区 Lua包管理工具Luarocks详解
- 问题-delphi XE2 Stack Overflow- save your work and restart CodeGear
问题现象:某一天,启动DLEPHI XE2 后,新建一个工程,双击一个事件,“Stack Overflow- save your work and restart CodeGear delphi xe ...
- hdoj 1495 非常可乐【bfs隐式图】
非常可乐 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- .NET中常见对象
.NET中六大内置对象:1.Response 2.Request 3.Session 4.Appliction 5.Server 6.Cookie System.Web.HttpCo ...
- SGU107——987654321 problem
For given number N you must output amount of N-digit numbers, such, that last digits of their square ...
- 【面试虐菜】—— Oracle中CHAR、VARCHAR的区别
1.CHAR. CHAR存储定长数据很方便,CHAR字段上的索引效率级高,比如定义char(10),那么不论你存储的数据是否达到了10个字节,都要占去10个字节的空间,不足的自动用空格填充,所以在读取 ...
- android 中view的绘制过程
view的绘制过程中分别会执行:onMeasure(会多次)计算view的大小,OnLayout(),确定控件的大小和位置 onDraw()绘制view 当Activity获得焦点时,它将被要求绘制自 ...
- FormMove
private { Private declarations } procedure WMMOVE(var Msg: TMessage); message WM_MOVE; proced ...
- Citrix服务器虚拟化之三十 XenApp 6.5发布流式应用程序
Citrix服务器虚拟化之三十 XenApp 6.5发布流式应用程序 XenApp可发布以下类型的资源向用户提供信息访问,这 ...