1.新建springboot项目,详情查看使用IDEA搭建一个简单的SpringBoot项目——详细过程_君当自强-CSDN博客_springboot项目搭建
2.搭建过程中遇到的问题如下:
@RunWith(SpringRunner.class)
@MapperScan("com.example.test")
@ComponentScan(value = "com.example.test.serviceImpl")
@SpringBootTest(classes= DemoApplication.class)
public class TestApplicationTests
springboot测试启动类不加@RunWith(SpringRunner.class),service注入不进去
不加MapperScan包扫描不到
@SpringBootApplication @MapperScan("com.example.test.mapper")
public class DemoApplication
启动类目录位置需要高于controller,不然扫描不到controller
spring:
datasource:
name: mysql
url: jdbc:mysql://localhost:3306/mysql?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC
username: root
password: 123
driver-class-name: com.mysql.jdbc.Driver
URL上不加serverTimezone
报错 The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone.
springboot内置tomcat端口为8080,访问路径为localhost:8080