Spring+springmvc+mybatis (SSM)

Source: Internet
Author: User

1.jdbc.properties

Jdbc.driverclassname=com.mysql.jdbc.Driverjdbc.url=jdbc:mysql://localhost:3306/jkdb? Characterencoding=utf-8jdbc.username=rootjdbc.password=123C3p0.pool.size.max=  - c3p0.pool.size.min=5C3p0.pool.size.ini=3c3p0.pool.size.increment =2
View Code

2.mybatis.xml

<?xml version="1.0" encoding="UTF-8" ? ><! DOCTYPE Configuration     " -//mybatis.org//dtd Config 3.0//en "    " HTTP://MYBATIS.ORG/DTD/MYBATIS-3-CONFIG.DTD "><configuration>    </configuration>    
View Code

3.bean.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:mvc="Http://www.springframework.org/schema/mvc"Xmlns:context="Http://www.springframework.org/schema/context"XMLNS:AOP="HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP"xmlns:tx="Http://www.springframework.org/schema/tx"xsi:schemalocation="Http://www.springframework.org/schema/beanshttp//www.springframework.org/schema/beans/spring-beans-3.0.xsdhttp//Www.springframework.org/schema/mvchttp//www.springframework.org/schema/mvc/spring-mvc-3.0.xsdhttp//Www.springframework.org/schema/contexthttp//www.springframework.org/schema/context/spring-context-3.0.xsdhttp//WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOPhttp//www.springframework.org/schema/aop/spring-aop-3.0.xsdhttp//Www.springframework.org/schema/txhttp//www.springframework.org/schema/tx/spring-tx-3.0.xsd "><!--managing service and DAO--<context:component-scanBase-package="Cn.itcast.jk.service,cn.itcast.jk.dao"/> <context:property-placeholder location="classpath:jdbc.properties"/> <!--database link information--<bean id="DataSource" class="Com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="Driverclass"Value="${jdbc.driverclassname}"/> <property name="Jdbcurl"Value="${jdbc.url}"/> <property name="User"Value="${jdbc.username}"/> <property name="Password"Value="${jdbc.password}"/> <property name="maxpoolsize"Value="${c3p0.pool.size.max}"/> <property name="minpoolsize"Value="${c3p0.pool.size.min}"/> <property name="initialpoolsize"Value="${c3p0.pool.size.ini}"/> <property name="acquireincrement"Value="${c3p0.pool.size.increment}"/> </bean> <!--sqlsessionfactory Spring and MyBatis integration--<bean id="sqlsessionfactory" class="Org.mybatis.spring.SqlSessionFactoryBean"> <property name="DataSource" ref="DataSource"/> <property name="configlocation"Value="Classpath:sqlMapConfig.xml"/> <property name="mapperlocations"Value="Classpath:cn/itcast/jk/mapper/*.xml"/> </bean> <!--transaction Management-<bean id="Txmanager" class="Org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="DataSource" ref="DataSource"/> </bean> <!--notification-<tx:advice id="Txadvice"Transaction-manager="Txmanager"> <tx:attributes> <tx:method name="find*"read-only="true"/> <tx:method name="get*"read-only="true"/> <tx:method name="view*"read-only="true"/> <tx:method name="insert*"propagation="REQUIRED"/> <tx:method name="update*"propagation="REQUIRED"/> <tx:method name="delete*"propagation="REQUIRED"/> <tx:method name="*"propagation="REQUIRED"/><!--prevent slip-through </tx:attributes> </tx:advice> <aop:config> <!--tangency Management There is a service method--<aop:pointcut expression="Execution (* cn.itcast.jk.service.*.* (..))"Id="Transactionpointcut"/> <!--enhancements for transaction control Advisor--<aop:advisor advice-ref="Txadvice"pointcut-ref="Transactionpointcut"/> </aop:config></beans>
View Code

4.springmvc.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:mvc="Http://www.springframework.org/schema/mvc"Xmlns:context="Http://www.springframework.org/schema/context"XMLNS:AOP="HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP"Xmlns:tx="Http://www.springframework.org/schema/tx"xsi:schemalocation="Http://www.springframework.org/schema/beanshttp//www.springframework.org/schema/beans/spring-beans-3.0.xsdhttp//Www.springframework.org/schema/mvchttp//www.springframework.org/schema/mvc/spring-mvc-3.0.xsdhttp//Www.springframework.org/schema/contexthttp//www.springframework.org/schema/context/spring-context-3.0.xsdhttp//WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOPhttp//www.springframework.org/schema/aop/spring-aop-3.0.xsdhttp//Www.springframework.org/schema/txhttp//www.springframework.org/schema/tx/spring-tx-3.0.xsd "><mvc:annotation-driven/> <!--Scan Controller--<context:component-scanBase-package="Cn.itcast.jk.controller"/> <!--internal Resource View Resolver--<bean id="Jspinternalresourceviewresolver" class="Org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix"Value="/web-inf/pages/"/> <property name="suffix"Value=""/> </bean></beans>
View Code

Spring+springmvc+mybatis (SSM)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.