相关配置
- springboot:2.7.2
- mybatis:3.5.11
- postgresql:42.3.6
- jdk:8
问题清单与解决措施
- 项目启动之后,无法使用postman调用本地接口。返回no message available:
- 调用方式为Post。调整postman的header,新增Content-Type为application/json
- 为方法入参加上@RequestBody注解
- Rest接口与启动类不在同一包下,新增@ComponentScan注解,指定扫描目录
- 项目启动过程中,提示Mapper类无法被自动装配
- 引入依赖包MyBatis Spring Boot Starter:2.1.3,使用MapperScan注解指定Mapper文件的扫描目录
- application.properties新增配置项mybatis.mapper-locations=classpath:mapper/*.xml
- 项目启动时,提示failed to configure a datasource
- application.properties新增如下配置项:
- application.properties新增如下配置项:
- 成功调用接口后,Mapper层报错,提示Driver org.postgresql.Driver claims to not accept jdbcUrl
- spring.datasource.url格式不正确。将postgres更正为postgresql,补充上默认数据库