2020-02-16 使用Mybatis Generator生成

2020-02-16  本文已影响0人  很菜的花椰菜

https://blog.csdn.net/AOBO516/article/details/90245203
https://blog.csdn.net/qq_38455201/article/details/79194792

自己测试一下
如何通过 maven 配置生成

首先,我在自己之前的项目中 project 下 生成了一个 module ,参考自己的项目 resource

image.png

然后第二步,在自己的 resources文件中创建 mapper等

image.png
image.png

第三步,在dao层的pom文件中加入相关依赖,好像是专用的,网上其他教程中说的不是这些

<dependencies>
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>1.3.1</version>
        </dependency>
        <dependency>
            <groupId>org.mybatis.generator</groupId>
            <artifactId>mybatis-generator-core</artifactId>
            <version>1.3.2</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
        </dependency>
    </dependencies>

第四步,增加mybatis-generator-config.xml和 MybatisGenerator

第五步,根据当前的项目 修改和配置 mybatis-generator-config.xml和 MybatisGenerator

比如生成文件的位置,插件的位置,生成包等的位置


image.png

第六步,创建

image.png

方法一:点击MybatisGenerator中的 main()函数,run一下,生成完这个样子


image.png

方法二:配置 configuration,和那个配置 tomcat一样的地方,但是这个我这里失败了

上一篇 下一篇

猜你喜欢

热点阅读