简单创建SpringBoot+Mybatis项目
创建一个简单的SpringBoot+Mybatis
-
开发工具及环境
- Eclipse
- JDK1.8
- Maven
-
开发过程
- 用Eclipse创建Maven项目
- 修改pom.xml文件
- 编写配置文件
- 编写业务代码
- 运行
用Eclipse创建Maven项目
- File-> New-> Project,搜索Maven,选择Maven Project。
- 按如下选择,点Next。
- 在下图中填写Group Id和Artifact Id,之后点击Finish。
修改pom.xml文件
在SpringBoot+Mybatis中,需要将相关包导入
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper-spring-boot-starter</artifactId>
<version>2.0.2</version>
</dependency>