Intellij IDEA中使用MyBatis-generator 自动生成MyBatis的xml文件、实体类以及dao接口文件

本文主要记录Intellij idea使用Mybatis - generator如何通过配置自动生成相关代码的过程。

 

1 pom.xml

本次在MAVEN中使用 mybatis-generator-maven-plugin插件来完成这个功能,maven配置如下:

<plugin>

<groupId>org.mybatis.generator</groupId>

<artifactId>mybatis-generator-maven-plugin</artifactId>

<version>1.3.6</version>

<configuration>

<configurationFile>

# 此处为generatorConfig.xml配置文件的路径

${basedir}/src/main/resources/generator/generatorConfig.xml

</configurationFile>

<overwrite>true</overwrite>

<verbose>true</verbose>

</configuration>

<dependencies>

<dependency>

<groupId>sqljdbc</groupId>

<artifactId>sqljdbc</artifactId>

<version>4</version>

<!-- system作用域的依赖项不会从maven仓库抓,而是从本地系统文件拿,一定要配合syste

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要创建一个spring boot + mybatis plus项目,你需要按照以下步骤进行操作: 1. 首先,确保你的pom.xml文件添加了必要的依赖。你需要添加mybatis plus的依赖,可以在pom.xml文件添加以下代码段: ``` <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.4.1</version> <optional>true</optional> </dependency> ``` 同时,你还需要添加spring-jdbc、mybatis-plus-generator和freemarker的依赖。可以在pom.xml文件添加以下代码段: ``` <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> </dependency> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.2.0</version> </dependency> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-generator</artifactId> <version>3.2.0</version> </dependency> <dependency> <groupId>org.freemarker</groupId> <artifactId>freemarker</artifactId> <version>2.3.30</version> </dependency> ``` 2. 接下来,你需要创建一个Spring Boot项目。你可以使用你喜欢的IDE,如IntelliJ IDEA或Eclipse,创建一个新的Spring Boot项目。 3. 在项目的配置文件(application.properties或application.yml),配置数据库连接信息。你需要提供数据库的URL、用户名和密码等信息。 4. 创建实体类和Mapper接口。你可以使用mybatis plus的代码生成器来自动生成实体类和Mapper接口。你可以在项目创建一个代码生成器的类,使用mybatis plus提供的相关API来生成代码。 5. 编写业务逻辑代码。根据你的需求,编写相应的Service和Controller类来处理业务逻辑。 6. 运行项目。你可以使用IDE提供的运行功能,或者使用命令行工具来运行项目。 通过以上步骤,你就可以成功创建一个spring boot + mybatis plus项目了。记得根据你的具体需求进行相应的配置和编码。祝你成功! #### 引用[.reference_title] - *1* *3* [搭建spring boot + mybatis plus项目](https://blog.csdn.net/weixin_41968788/article/details/106542661)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [新建一个Spring Boot+MyBatis-Plus项目](https://blog.csdn.net/hyh17808770899/article/details/122076377)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值