怎末使用My bits 框架来实现增删改查

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
    PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
    "http://mybatis.org/dtd/mybatis-3-config.dtd">

<configuration>
  <properties resource="druid.properties"></properties><!-- 引用加载数据库的配置文件-->
  <settings>
    <setting name="useGeneratedKeys" value="false"/>
    <setting name="useColumnLabel" value="true"/>
    <setting name="mapUnderscoreToCamelCase" value="true"/>
  </settings>


  <typeAliases>
<!--    <typeAlias alias="Category" type="Jopo.Category"/>-->
    <package name="Jopo"/>
<!-- 将引用的类制定在那个包下面不用在引用类前加包名了-->
  </typeAliases>
  <plugins>
    <plugin interceptor="com.github.pagehelper.PageInterceptor">
      <property name="helperDialect" value="mysql"/>
      <property name="reasonable" value="true"/>
    </plugin>
  </plugins>
  <environments default="development">
    <environment id="development">
      <transactionManager type="JDBC">
        <property name="" value=""/>
      </transactionManager>
      <dataSource type="UNPOOLED">
       <property name="driver" value="${driveClassName}" /><!-- 引用的加载数据库的驱动-->
        <property name="url" value="${url}"/><!-- 引用的加载数据库的驱动路径-->
        <property name="username" value="${username}"/><!-- 数据库账户-->
        <property name="password" value="${password}"/><!-- 数据库密码-->
      </dataSource>
    </environment>
  </environments>
<!--mapper里面写的是引用的配置文件-->
  <mappers>
    <mapper resource="mybatis/CategoryMapper.xml"/>
    <mapper resource="mybatis/IdColumnMapper.xml"/>
    <mapper resource="mybatis/UuidColumnMapper.xml"/>
    <mapper resource="mybatis/UserMapper.xml"/>
  </mappers>

</configuration>

引用数据库文件文件类型"properties文件"

 

driveClassName=com.mysql.cj.jdbc.Driver
url=jdbc:mysql://localhost:3306/java0412
username=root
password=123456
initialSize=5
maxWait=5000
maxActive=10

引用的子类配置文件

<?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="mapper.CategoryMapper">
<select id="select" resultType="Jopo.Category" >
select * from category order by cid asc
</select>
  <select id="selectbyid" resultType="Jopo.Category" parameterType="String">
select * from category where cid=#{id}
  </select>
<insert id="insert" parameterType="Jopo.Category">
  insert into category(cid,cname)values (#{cId},#{cName})
</insert>
<update id="updata" parameterType="Jopo.Category">
  update category set cname=#{cName} where cid=#{cId}
</update>
  <delete id="delete" parameterType="String">
    delete from category where cId=#{cId}
  </delete>
</mapper>









评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值