1.打开SpringToolSuite4.exe。
2.在File菜单下面的new下面的spring starter Project
3.点击next,选择Spring Boot Version为2.7.11,以及Spring Web
.
4.点击Finsh,然后在pom.xml中引入,第一次运行只要这个配置
<dependency>
<groupId>cn.miw</groupId>
<artifactId>genutil</artifactId>
<version>0.5.3</version>
</dependency>
5.还需要在yal文件中写入数据库配置,根据自己用的数据库编写,第二步运行才把数据库依赖和mybatis-plus依赖引入
引入数据库依赖
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<scope>runtime</scope>
</dependency>
或者其他数据库依赖。
6.还要引入mybatis-plus
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.3.1</version>
</dependency>
6.第一次运行在Test类中这样写
@SpringBootTest
class Demo2ApplicationTests {
@Test
void contextLoads() {
new GenUtil(null).gen("cn.miw.demo2", null);
}
}
7.第二次运行在test中这样写
@SpringBootTest
class Demo2ApplicationTests {
@Autowired DataSource dataSource;
@Test
void contextLoads() {
new GenUtil(dataSource).gen("cn.miw.demo2", null);
}
}
第二次运行需要连接数据库
7.new GenUtil(dataSource).gen("cn.miw.demo2", null);会顺着数据库中的表全部创建。
8.运行test类,创建成功。