• 配置文件


    spring整合mybatis

    # jdbc配置文件
    jdbc.driver=com.mysql.cj.jdbc.Driver
    jdbc.url=jdbc:mysql://localhost:3306/spring_db?serverTimezone=Asia/Shanghai
    jdbc.username=root
    jdbc.password=xxxxx
    
    <?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:context="http://www.springframework.org/schema/context"
           xmlns:aop="http://www.springframework.org/schema/aop"
           xsi:schemaLocation="http://www.springframework.org/schema/beans
            https://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/context
            https://www.springframework.org/schema/context/spring-context.xsd
            http://www.springframework.org/schema/aop
            https://www.springframework.org/schema/aop/spring-aop.xsd">
    
        <context:property-placeholder location="classpath:*.properties"/>
    
        <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
            <property name="driverClassName" value="${jdbc.driver}"/>
            <property name="url" value="${jdbc.url}"/>
            <property name="username" value="${jdbc.username}"/>
            <property name="password" value="${jdbc.password}"/>
        </bean>
    
        <bean id="accountService" class="com.ls.service.impl.AccountServiceImpl">
            <property name="accountDao" ref="accountDao"/>
            <!--<property name="dataSource" ref="dataSource"/>-->
        </bean>
    
        <bean class="org.mybatis.spring.SqlSessionFactoryBean">
            <property name="dataSource" ref="dataSource"/>
            <property name="typeAliasesPackage" value="com.ls.domain"/>
        </bean>
    
        <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
            <property name="basePackage" value="com.ls.dao"/>
        </bean>
    </beans>
    
    <!--mybatismapper中的配置文件 -->
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE mapper
            PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
            "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
    <mapper namespace="com.ls.dao.AccountDao">
    
        <update id="inMoney">
            update account set money = money + #{money} where name = #{name}
        </update>
    
        <update id="outMoney">
            update account set money = money - #{money} where name = #{name}
        </update>
    
    </mapper>
    
  • 相关阅读:
    调用Android中的软键盘
    EditText图文混排
    android开源框架
    Android 菜单(OptionMenu)
    onRetainNonConfigurationInstance和getLastNonConfigurationInstance
    Android HttpClient基本使用方法
    Eclipse中文注释乱码解决
    mysql怎么定义外键
    javaproject积累——java 反射 invoke
    Floodlight 启动过程分析
  • 原文地址:https://www.cnblogs.com/rhy2103/p/16414664.html
Copyright © 2020-2023  润新知