今天做个小demo,springboot整合mybatis进行增删改查操作,适合新手小白学习,亲测可以运行,话不多说,开搞。
1.打开idea->选择new project ,然后选择Spring Initializr,如下:
2.下一步,Java Version 记得选成8,不然后续会出问题
3.下一步,选择如下图:
4.最后一步,给项目起一个名字,然后把他放在一个文件夹中即可
5.项目建好以后,目录结构如下图所示
6.pom文件大家就复制我的吧,不然可能有点出入(注意从properties开始复制,别删多了)
<properties> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jdbc</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>2.2.2</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <sco