springmvc:整合ssm(spring层)
2021-01-30 11:14
标签:参数 扫描 整合 app http actor enc 事务配置 oca 1、spring整合dao层:创建一个配置文件(spring-dao.xml) 整合以前是mybatis管理,现在是交给spring容器进行管理 数据库参数的配置文件:jdbc.properties 2、spring整合service层: 3、在applicationContext.xml配置文件中将上述的两个spring的配置文件导入进来: springmvc:整合ssm(spring层) 标签:参数 扫描 整合 app http actor enc 事务配置 oca 原文地址:https://www.cnblogs.com/zhai1997/p/12820860.htmlxml version="1.0" encoding="UTF-8"?>
beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns="http://www.springframework.org/schema/beans"
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/context
http://www.springframework.org/schema/context/spring-context.xsd">
context:property-placeholder location="classpath:jdbc.properties">context:property-placeholder>
bean name="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
property name="driverClass" value="${jdbc.driver}">property>
property name="jdbcUrl" value="${jdbc.url}">property>
property name="user" value="${jdbc.username}">property>
property name="password" value="${jdbc.password}">property>
bean>
bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
property name="dataSource" ref="dataSource">property>
property name="configLocation" value="classpath:mybatis-config.xml">property>
bean>
bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
property name="sqlSessionFactoryBeanName" value="sqlSessionFactory">property>
property name="basePackage" value="pers.zhb.dao">property>
bean>
beans>
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/stu_mangement
jdbc.username=root
jdbc.password=root
xml version="1.0" encoding="UTF-8"?>
beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns="http://www.springframework.org/schema/beans"
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/context
http://www.springframework.org/schema/context/spring-context.xsd">
import resource="classpath:spring-dao.xml">import>
context:component-scan base-package="pers.zhb.service">context:component-scan>
bean id="TeacherServiceImpl" class="pers.zhb.service.TeacherServiceImpl">
property name="teacherMapper" ref="teacherMapper"/>
bean>
bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
property name="dataSource" ref="dataSource">property>
bean>
beans>
xml version="1.0" encoding="UTF-8"?>
beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd">
import resource="classpath:spring-dao.xml">import>
import resource="classpath:spring-service.xml">import>
beans>
文章标题:springmvc:整合ssm(spring层)
文章链接:http://soscw.com/index.php/essay/49090.html