springboot快速集成ssm

在springboot中快速搭建ssm环境

首先创建springboot项目
在pom.xml中导入依赖
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<dependencies>
<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>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- alibaba的连接池 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.20</version>
</dependency>
<!-- mysql 数据库驱动. -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!-- mybatis整合springboot的依赖. -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.18</version>
<scope>provided</scope>
</dependency>
</dependencies>

在springboot的配置文件(application.yml)中添加dataSource配置
1
2
3
4
5
6
7
8
9
10
11
spring:
dataSource:
#以mysql为例
driverClass:com.mysql.jsbc.Driver
username:用户名
password:密码
url:数据库连接
type: 连接池类型,不写为springboot默认的连接池s

mybatis:
mapper-locations:classpath:xx/xxx/xxx/*Mapper.xmls
在springboot的配置类添加注解
1
@MapperScan("Mapper的全限定名")
好了,完事儿

Comments: