SSM框架的搭建完整步骤.docx

上传人:b****3 文档编号:787413 上传时间:2022-10-13 格式:DOCX 页数:18 大小:90.66KB
下载 相关 举报
SSM框架的搭建完整步骤.docx_第1页
第1页 / 共18页
SSM框架的搭建完整步骤.docx_第2页
第2页 / 共18页
SSM框架的搭建完整步骤.docx_第3页
第3页 / 共18页
SSM框架的搭建完整步骤.docx_第4页
第4页 / 共18页
SSM框架的搭建完整步骤.docx_第5页
第5页 / 共18页
点击查看更多>>
下载资源
资源描述

SSM框架的搭建完整步骤.docx

《SSM框架的搭建完整步骤.docx》由会员分享,可在线阅读,更多相关《SSM框架的搭建完整步骤.docx(18页珍藏版)》请在冰豆网上搜索。

SSM框架的搭建完整步骤.docx

SSM框架的搭建完整步骤

SSM框架的搭建

一、新建javaweb项目,并建好相应的包结构

二、添加项目jar到lib目录下

三、在config包中新建配置文件

sping-mvc.xml,内容如下:

xmlversion="1.0"encoding="UTF-8"?

>

//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-4.0.xsd

http:

//www.springframework.org/schema/mvc

http:

//www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">

--注解扫描包-->

component-scanbase-package="com.hyg.im"/>

--开启注解-->

annotation-driven/>

spring-common.xml内容如下:

xmlversion="1.0"encoding="UTF-8"?

>

//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"

xsi:

schemaLocation="

http:

//www.springframework.org/schema/beans

http:

//www.springframework.org/schema/beans/spring-beans-4.0.xsd

http:

//www.springframework.org/schema/context

http:

//www.springframework.org/schema/context/spring-context-4.0.xsd

http:

//www.springframework.org/schema/tx

http:

//www.springframework.org/schema/tx/spring-tx-4.0.xsd">

--1.数据源:

DriverManagerDataSource-->

class="org.springframework.jdbc.datasource.DriverManagerDataSource">

mysql:

//localhost:

3306/test"/>

--

2.mybatis的SqlSession的工厂:

SqlSessionFactoryBeandataSource:

引用数据源

MyBatis定义数据源,同意加载配置

-->

--

3.mybatis自动扫描加载Sql映射文件/接口:

MapperScannerConfigurersqlSessionFactory

basePackage:

指定sql映射文件/接口所在的包(自动扫描)

-->

--

4.事务管理:

DataSourceTransactionManagerdataSource:

引用上面定义的数据源

-->

class="org.springframework.jdbc.datasource.DataSourceTransactionManager">

--5.使用声明式事务

transaction-manager:

引用上面定义的事务管理器

-->

annotation-driventransaction-manager="txManager"/>

四、配置web.xml,内容如下:

xmlversion="1.0"encoding="UTF-8"?

>

xmlns:

xsi="http:

//www.w3.org/2001/XMLSchema-instance"

xsi:

schemaLocation="

--加载Spring容器配置-->

org.springframework.web.context.ContextLoaderListener

--设置Spring容器加载所有的配置文件的路径-->

contextConfigLocation

classpath*:

config/spring-*.xml

--配置SpringMVC核心控制器-->

springMVC

org.springframework.web.servlet.DispatcherServlet

--配置初始配置化文件,前面contextConfigLocation看情况二选一-->

contextConfigLocation

classpath*:

config/spring-mvc.xml

--启动加载一次-->

1

--为DispatcherServlet建立映射-->

springMVC

--此处可以可以配置成*.do,对应struts的后缀习惯-->

/

default

*.html

default

*.gif

default

*.css

default

*.js

default

*.jpg

default

*.png

--防止Spring内存溢出监听器-->

org.springframework.web.util.IntrospectorCleanupListener<

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 解决方案 > 学习计划

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1