SpringBoot 创建过程
1.按照一下图示操作
2.在下面写上自己需要的xml
<?xml version="1.0" encoding="UTF-8"?>
4.0.0
org.springframework.boot
spring-boot-starter-parent
2.7.2
com.example
SpringTest
0.0.1-SNAPSHOT
SpringTest
SpringTest
<java.version>11</java.version>
org.springframework.boot
spring-boot-starter
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.5</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- mysql数据库驱动包 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.15</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<!--web依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.2.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
3.配置相应的功能
3.1 首先配置普通的链接处理
其中RestController是@Controller+@ResponseBody的组合
其中的Dao是为了处理Mybatis用的 Account是pojo
如果这个Dao真的能实现操作数据库还需要两个重要步骤
用MapperScan进行扫描
还需要配置数据链接,驱动器,用户,密码,和Mybatis需要的别名包和mapper位置的指向
3. 代码链接
https://gitee.com/sunjianhua112/lagou-study/tree/master/codePratice/