为什么我的mapper.xml 里面的代码生成了两边.... pojo dao 没问题

来源:5-10 mybatis三剑客之mybatis-generator生成数据对象和时间戳优化

JakePrim

2020-04-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="com.prim.mall.dao.CategoryMapper">
  <resultMap id="BaseResultMap" type="com.prim.mall.pojo.Category">
    <constructor>
      <idArg column="id" javaType="java.lang.Integer" jdbcType="INTEGER" />
      <arg column="parent_id" javaType="java.lang.Integer" jdbcType="INTEGER" />
      <arg column="name" javaType="java.lang.String" jdbcType="VARCHAR" />
      <arg column="status" javaType="java.lang.Boolean" jdbcType="BIT" />
      <arg column="sort_order" javaType="java.lang.Integer" jdbcType="INTEGER" />
      <arg column="create_time" javaType="java.util.Date" jdbcType="TIMESTAMP" />
      <arg column="update_time" javaType="java.util.Date" jdbcType="TIMESTAMP" />
    </constructor>
  </resultMap>
  <sql id="Base_Column_List">
    id, parent_id, name, status, sort_order, create_time, update_time
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from mmall_category
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from mmall_category
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.prim.mall.pojo.Category">
    insert into mmall_category (id, parent_id, name, 
      status, sort_order, create_time, 
      update_time)
    values (#{id,jdbcType=INTEGER}, #{parentId,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, 
      #{status,jdbcType=BIT}, #{sortOrder,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, 
      #{updateTime,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" parameterType="com.prim.mall.pojo.Category">
    insert into mmall_category
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="parentId != null">
        parent_id,
      </if>
      <if test="name != null">
        name,
      </if>
      <if test="status != null">
        status,
      </if>
      <if test="sortOrder != null">
        sort_order,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="updateTime != null">
        update_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="parentId != null">
        #{parentId,jdbcType=INTEGER},
      </if>
      <if test="name != null">
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="status != null">
        #{status,jdbcType=BIT},
      </if>
      <if test="sortOrder != null">
        #{sortOrder,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.prim.mall.pojo.Category">
    update mmall_category
    <set>
      <if test="parentId != null">
        parent_id = #{parentId,jdbcType=INTEGER},
      </if>
      <if test="name != null">
        name = #{name,jdbcType=VARCHAR},
      </if>
      <if test="status != null">
        status = #{status,jdbcType=BIT},
      </if>
      <if test="sortOrder != null">
        sort_order = #{sortOrder,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateTime != null">
        update_time = #{updateTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.prim.mall.pojo.Category">
    update mmall_category
    set parent_id = #{parentId,jdbcType=INTEGER},
      name = #{name,jdbcType=VARCHAR},
      status = #{status,jdbcType=BIT},
      sort_order = #{sortOrder,jdbcType=INTEGER},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      update_time = #{updateTime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <resultMap id="BaseResultMap" type="com.prim.mall.pojo.Category">
    <constructor>
      <idArg column="id" javaType="java.lang.Integer" jdbcType="INTEGER" />
      <arg column="parent_id" javaType="java.lang.Integer" jdbcType="INTEGER" />
      <arg column="name" javaType="java.lang.String" jdbcType="VARCHAR" />
      <arg column="status" javaType="java.lang.Integer" jdbcType="INTEGER" />
      <arg column="sort_order" javaType="java.lang.Integer" jdbcType="INTEGER" />
      <arg column="create_time" javaType="java.util.Date" jdbcType="TIMESTAMP" />
      <arg column="update_time" javaType="java.util.Date" jdbcType="TIMESTAMP" />
    </constructor>
  </resultMap>
  <sql id="Base_Column_List">
    id, parent_id, name, status, sort_order, create_time, update_time
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from mmall_category
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from mmall_category
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.prim.mall.pojo.Category">
    insert into mmall_category (id, parent_id, name, 
      status, sort_order, create_time, 
      update_time)
    values (#{id,jdbcType=INTEGER}, #{parentId,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, 
      #{status,jdbcType=INTEGER}, #{sortOrder,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, 
      #{updateTime,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" parameterType="com.prim.mall.pojo.Category">
    insert into mmall_category
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="parentId != null">
        parent_id,
      </if>
      <if test="name != null">
        name,
      </if>
      <if test="status != null">
        status,
      </if>
      <if test="sortOrder != null">
        sort_order,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="updateTime != null">
        update_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="parentId != null">
        #{parentId,jdbcType=INTEGER},
      </if>
      <if test="name != null">
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="status != null">
        #{status,jdbcType=INTEGER},
      </if>
      <if test="sortOrder != null">
        #{sortOrder,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.prim.mall.pojo.Category">
    update mmall_category
    <set>
      <if test="parentId != null">
        parent_id = #{parentId,jdbcType=INTEGER},
      </if>
      <if test="name != null">
        name = #{name,jdbcType=VARCHAR},
      </if>
      <if test="status != null">
        status = #{status,jdbcType=INTEGER},
      </if>
      <if test="sortOrder != null">
        sort_order = #{sortOrder,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateTime != null">
        update_time = #{updateTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.prim.mall.pojo.Category">
    update mmall_category
    set parent_id = #{parentId,jdbcType=INTEGER},
      name = #{name,jdbcType=VARCHAR},
      status = #{status,jdbcType=INTEGER},
      sort_order = #{sortOrder,jdbcType=INTEGER},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      update_time = #{updateTime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>
</mapper>
写回答

1回答

JakePrim

提问者

2020-04-10

这是运行信息,配置没有问题啊

"/Applications/IntelliJ IDEA.app/Contents/jbr/Contents/Home/bin/java" -Dmaven.multiModuleProjectDirectory=/Users/prim/java/java-workspace/ssm-shop "-Dmaven.home=/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3" "-Dclassworlds.conf=/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/bin/m2.conf" "-Dmaven.ext.class.path=/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven-event-listener.jar" "-javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=53102:/Applications/IntelliJ IDEA.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath "/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/boot/plexus-classworlds-2.6.0.jar" org.codehaus.classworlds.Launcher -Didea.version2019.3.4 org.mybatis.generator:mybatis-generator-maven-plugin:1.3.2:generate
[INFO] Scanning for projects...
[INFO] 
[INFO] --------------------------< com.prim:ssmshop >--------------------------
[INFO] Building ssmshop Maven Webapp 1.0-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO] 
[INFO] --- mybatis-generator-maven-plugin:1.3.2:generate (default-cli) @ ssmshop ---
[INFO] Connecting to the Database
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
[INFO] Introspecting table mmall_shipping
log4j:WARN No appenders could be found for logger (org.mybatis.generator.internal.db.DatabaseIntrospector).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
[INFO] Introspecting table mmall_cart
[INFO] Introspecting table mmall_cart_item
[INFO] Introspecting table mmall_category
[INFO] Introspecting table mmall_order
[INFO] Introspecting table mmall_order_item
[INFO] Introspecting table mmall_pay_info
[INFO] Introspecting table mmall_product
[INFO] Introspecting table mmall_user
[INFO] Generating Record class for table mmall_shipping
[INFO] Generating Mapper Interface for table mmall_shipping
[INFO] Generating SQL Map for table mmall_shipping
[INFO] Generating Record class for table mmall_shipping
[INFO] Generating Mapper Interface for table mmall_shipping
[INFO] Generating SQL Map for table mmall_shipping
[INFO] Generating Record class for table mmall_cart
[INFO] Generating Mapper Interface for table mmall_cart
[INFO] Generating SQL Map for table mmall_cart
[INFO] Generating Record class for table mmall_cart
[INFO] Generating Mapper Interface for table mmall_cart
[INFO] Generating SQL Map for table mmall_cart
[INFO] Generating Record class for table mmall_category
[INFO] Generating Mapper Interface for table mmall_category
[INFO] Generating SQL Map for table mmall_category
[INFO] Generating Record class for table mmall_category
[INFO] Generating Mapper Interface for table mmall_category
[INFO] Generating SQL Map for table mmall_category
[INFO] Generating Record class for table mmall_order
[INFO] Generating Mapper Interface for table mmall_order
[INFO] Generating SQL Map for table mmall_order
[INFO] Generating Record class for table mmall_order
[INFO] Generating Mapper Interface for table mmall_order
[INFO] Generating SQL Map for table mmall_order
[INFO] Generating Record class for table mmall_order_item
[INFO] Generating Mapper Interface for table mmall_order_item
[INFO] Generating SQL Map for table mmall_order_item
[INFO] Generating Record class for table mmall_order_item
[INFO] Generating Mapper Interface for table mmall_order_item
[INFO] Generating SQL Map for table mmall_order_item
[INFO] Generating Record class for table mmall_pay_info
[INFO] Generating Mapper Interface for table mmall_pay_info
[INFO] Generating SQL Map for table mmall_pay_info
[INFO] Generating Record class for table mmall_pay_info
[INFO] Generating Mapper Interface for table mmall_pay_info
[INFO] Generating SQL Map for table mmall_pay_info
[INFO] Generating Record class for table mmall_product
[INFO] Generating Mapper Interface for table mmall_product
[INFO] Generating SQL Map for table mmall_product
[INFO] Generating Record class for table mmall_product
[INFO] Generating Mapper Interface for table mmall_product
[INFO] Generating SQL Map for table mmall_product
[INFO] Generating Record class for table mmall_user
[INFO] Generating Mapper Interface for table mmall_user
[INFO] Generating SQL Map for table mmall_user
[INFO] Generating Record class for table mmall_user
[INFO] Generating Mapper Interface for table mmall_user
[INFO] Generating SQL Map for table mmall_user
[INFO] Saving file ShippingMapper.xml
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.mybatis.generator.internal.DomWriter (file:/Users/prim/.m2/repository/org/mybatis/generator/mybatis-generator-core/1.3.2/mybatis-generator-core-1.3.2.jar) to method com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.getXmlVersion()
WARNING: Please consider reporting this to the maintainers of org.mybatis.generator.internal.DomWriter
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[INFO] Saving file ShippingMapper.xml
[INFO] Saving file CartMapper.xml
[INFO] Saving file CartMapper.xml
[INFO] Saving file CategoryMapper.xml
[INFO] Saving file CategoryMapper.xml
[INFO] Saving file OrderMapper.xml
[INFO] Saving file OrderMapper.xml
[INFO] Saving file OrderItemMapper.xml
[INFO] Saving file OrderItemMapper.xml
[INFO] Saving file PayInfoMapper.xml
[INFO] Saving file PayInfoMapper.xml
[INFO] Saving file ProductMapper.xml
[INFO] Saving file ProductMapper.xml
[INFO] Saving file UserMapper.xml
[INFO] Saving file UserMapper.xml
[INFO] Saving file Shipping.java
[INFO] Saving file ShippingMapper.java
[INFO] Saving file Shipping.java
[INFO] Saving file ShippingMapper.java
[INFO] Saving file Cart.java
[INFO] Saving file CartMapper.java
[INFO] Saving file Cart.java
[INFO] Saving file CartMapper.java
[INFO] Saving file Category.java
[INFO] Saving file CategoryMapper.java
[INFO] Saving file Category.java
[INFO] Saving file CategoryMapper.java
[INFO] Saving file Order.java
[INFO] Saving file OrderMapper.java
[INFO] Saving file Order.java
[INFO] Saving file OrderMapper.java
[INFO] Saving file OrderItem.java
[INFO] Saving file OrderItemMapper.java
[INFO] Saving file OrderItem.java
[INFO] Saving file OrderItemMapper.java
[INFO] Saving file PayInfo.java
[INFO] Saving file PayInfoMapper.java
[INFO] Saving file PayInfo.java
[INFO] Saving file PayInfoMapper.java
[INFO] Saving file Product.java
[INFO] Saving file ProductMapper.java
[INFO] Saving file Product.java
[INFO] Saving file ProductMapper.java
[INFO] Saving file User.java
[INFO] Saving file UserMapper.java
[INFO] Saving file User.java
[INFO] Saving file UserMapper.java
[WARNING] Table configuration with catalog null, schema null, and table mmall_cart_item did not resolve to any tables
[WARNING] Existing file /Users/prim/java/java-workspace/ssm-shop/./src/main/java/com/prim/mall/pojo/Shipping.java was overwritten
[WARNING] Existing file /Users/prim/java/java-workspace/ssm-shop/./src/main/java/com/prim/mall/dao/ShippingMapper.java was overwritten
[WARNING] Existing file /Users/prim/java/java-workspace/ssm-shop/./src/main/java/com/prim/mall/pojo/Cart.java was overwritten
[WARNING] Existing file /Users/prim/java/java-workspace/ssm-shop/./src/main/java/com/prim/mall/dao/CartMapper.java was overwritten
[WARNING] Existing file /Users/prim/java/java-workspace/ssm-shop/./src/main/java/com/prim/mall/pojo/Category.java was overwritten
[WARNING] Existing file /Users/prim/java/java-workspace/ssm-shop/./src/main/java/com/prim/mall/dao/CategoryMapper.java was overwritten
[WARNING] Existing file /Users/prim/java/java-workspace/ssm-shop/./src/main/java/com/prim/mall/pojo/Order.java was overwritten
[WARNING] Existing file /Users/prim/java/java-workspace/ssm-shop/./src/main/java/com/prim/mall/dao/OrderMapper.java was overwritten
[WARNING] Existing file /Users/prim/java/java-workspace/ssm-shop/./src/main/java/com/prim/mall/pojo/OrderItem.java was overwritten
[WARNING] Existing file /Users/prim/java/java-workspace/ssm-shop/./src/main/java/com/prim/mall/dao/OrderItemMapper.java was overwritten
[WARNING] Existing file /Users/prim/java/java-workspace/ssm-shop/./src/main/java/com/prim/mall/pojo/PayInfo.java was overwritten
[WARNING] Existing file /Users/prim/java/java-workspace/ssm-shop/./src/main/java/com/prim/mall/dao/PayInfoMapper.java was overwritten
[WARNING] Existing file /Users/prim/java/java-workspace/ssm-shop/./src/main/java/com/prim/mall/pojo/Product.java was overwritten
[WARNING] Existing file /Users/prim/java/java-workspace/ssm-shop/./src/main/java/com/prim/mall/dao/ProductMapper.java was overwritten
[WARNING] Existing file /Users/prim/java/java-workspace/ssm-shop/./src/main/java/com/prim/mall/pojo/User.java was overwritten
[WARNING] Existing file /Users/prim/java/java-workspace/ssm-shop/./src/main/java/com/prim/mall/dao/UserMapper.java was overwritten
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  6.330 s
[INFO] Finished at: 2020-04-10T23:14:12+08:00
[INFO] ------------------------------------------------------------------------


0
0

从0开始 独立完成企业级Java电商网站服务端开发

前后端分离,数据库接口设计,架构设计,功能开发,上线运维

9476 学习 · 8804 问题

查看课程