在mapper.xml文件中的resultMap的type或者parameterType会用到自定义的POJO。例如:

<mapper namespace="com.example.demo.mapper.UserMapper">
    <select >
        insert into user(username,password) value (#{username},#{password})
    </insert>
</mapper>
其中resultType=“User”中,User就是自定义的POJO,此时可以使用完全限定名来指定这些POJO的引用,例如:

<select >
第二种方法就是使用mybatis.type-aliases-package来指定POJO扫描包来让mybatis自动扫描到自定义的POJO。

在application.propertites配置文件中配置如下信息:mybatis.type-aliases-package=com.example.entity

mybatis.type-aliases-package=com.example.demo.entity

相关文章:

  • 2021-10-24
  • 2021-07-10
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-25
  • 2022-01-22
  • 2022-12-23
  • 2021-11-25
相关资源
相似解决方案