1.使用spring Initializr快速搭建springboot框架
2.然后导入依赖
<properties>
<java.version>1.8</java.version>
<mysql.version>5.7</mysql.version>
</properties>
<dependencies>
<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.3.0</version>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.0.33</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
3.在resources目录下创建一个yml文件,里面写上端口号,注册驱动和mybatis相关配置
#web
#端口号和项目路径
server:
port: 8000
servlet:
context-path: /day71
#数据源
spring:
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/day16?serverTimezone=UTC&characterEncoding=utf8
username: root
password: root
#mybatis相关的映射文件路径,别名,扫描等
mybatis:
mapper-locations: classpath:mapper/*.xml #映射文件路径
type-aliases-package: com.pojo #别名包扫描
一个很简单的ssm框架就搭建好了。
这里注意的是mysql8的依赖已经更改为mysql-connector-j