spring+springMVC+mybatis综合配置

本文详细介绍了如何将Spring、SpringMVC和Mybatis进行综合配置,从配置applicationContext.xml和db.property文件开始,到配置springmvc.xml、generator.xml、log4j.property以及web.xml。接着,编写service服务层代码和Userservice接口的实现。最后,使用ZUI前端框架进行页面开发,并编写controller层,实现了用户登录功能。
摘要由CSDN通过智能技术生成

源代码下载:SSM实现用户登陆

前面讲过了 spring+mybatis的配置 spring+mybatis

只要再加上spring MVC  spring MVC基础     就组合成了SSM框架

1、配置applicationContext.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:context="http://www.springframework.org/schema/context" 
	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.xsd
		http://www.springframework.org/schema/tx
		http://www.springframework.org/schema/tx/spring-tx.xsd 
		http://www.springframework.org/schema/aop 
		http://www.springframework.org/schema/aop/spring-aop-4.3.xsd ">
	
    <!-- 引入数据库配置文件 -->
    <context:property-placeholder location="classpath:com/ssmTest/system/config/db.properties"/>
	<!-- 数据源 -->
	<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
		<property name="driverClass" value="${jdbc.driver}"/>
        <property name="jdbcUrl" value="${jdbc.url}"/>
        <property name="user" value="${jdbc.username}"/>
        <property name="password" value="${jdbc.password}"/>
        <!-- 初始连接池大小  -->
        <property name="initialPoolSize" value="${jdbc.initialPoolSize}"/>
        <!-- 连接池中连接最小个数 -->
        <property name="minPoolSize" value="${jdbc.minPoolSize}"/>
        <!-- 连接池中连接最大个数 -->
        <property name="maxPoolSize" value="${jdbc.maxPoolSize}"/>
	</bean>	
	
	<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
	      <property name="dataSource" ref="dataSource"></property>
	</bean>
	
	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
	      <property name="basePackage" value="com.ssmTest.system.*.*.mapper"></property>   
	</bean>
	
	<!-- 配置注解扫描 用   @类名   的原因在这配置 -->
    <context:component-scan base-package="com.ssmTest.system.*.*.service"></context:component-scan>
	<context:component-scan base-package="com.ssmTest.system.*.*.pojo"></context:component-scan>
	
	  <!-- 配置事务管理 -->
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <!-- 注入数据源  保证了数据库的四大特性-->
        <property name="dataSource" ref="dataSource"></property>
    </bean>
    <!-- 通知 -->
    <tx:advice id="txAdvice" transaction-manager="transactionManager">
        <tx:attributes>
            <!-- 传播行为 每次调用这些方法都会启动 事务管理  每个在config里配置的方法都要以以下方式开头-->
            <tx:method name="save*" propagation="REQUIRED" />
            <tx:method name="insert*" propagation="REQUIRED" />
            <tx:method name="delete*" propagation="REQUIRED" />
            <tx:method name="update*" propagation="R
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

陈(chen)

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值