MybatisPlus+SpringBoot 自生成和配置 [简单项目-二]

MybatisPlus在SpringBoot中的使用

前一篇[Idea新建简单的springboot+mysql项目]:https://www.cnblogs.com/sword-js/p/14092758.html

步骤一

在pom.xml中引入Mybatis-plus和Velocity

        <!-- https://mvnrepository.com/artifact/com.baomidou/mybatis-plus-boot-starter -->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.1.0</version>
        </dependency>
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-generator</artifactId>
            <version>3.1.0</version>
        </dependency>

        <!--引入Velocity 保证Mybatis-plus生成器能正常运行-->
        <dependency>
            <groupId>org.apache.velocity</groupId>
            <artifactId>velocity-engine-core</artifactId>
            <version>2.1</version>
        </dependency>

步骤二

添加生成器和模板

CodeGenerator.java

controller.vm 该模板限制了表的主键id格式必须例如(表名 friend 主键 friendId、表名friend_data 主键 friendDataId)

步骤三

运行 CodeGenerator

步骤四

不要忘记启动类的配置,运行

MybatisPlus约定优于配置无法适用(不知道是否只有我,还是要配什么其他东西~~~)

后一篇[添加shiro]:https://www.cnblogs.com/sword-js/p/14092869.html

posted @ 2020-12-06 14:51  炼精工坊  阅读(144)  评论(0)    收藏  举报