SpringBoot框架用于实战(可直接下载源码进行拓展)
步骤:
- 创建数据库mr_wen,新建两条测试数据
- 创建SpringBoot项目
- 编写代码块,并进行单元测试
创建数据库mr_wen,新建两条测试数据
-
create DATABASE mr_wen; use mr_wen; create table `product_category` ( `category_id` int not null auto_increment, `category_name` varchar(64) not null , `category_type` int not null , primary key (`category_id`) );
创建SpringBoot项目(图解)
创建项目
创建完成
编写代码块
- 检查并导入依赖(pom.xml)
-
<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> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId