- 2022.9.6
- Description: Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
原因:因为依赖别的项目的pom文件导入了mybatis的数据源依赖,项目启动时会进行自动配置,而我的这个项目没有使用数据源相关操作,所以报了异常。 解决:@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
- 2022.9.16
devTools热部署没效果 看看Settings里面Buid project automaticlly有没有选上  - 2022.9.17
javax.servlet.ServletException: Circular view path [saveuser]: would dispatch back to the current handler URL [/saveuser] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.
解决方法:将控制器类加上@RestController 或者是方法上加@ResponseBody @RequestMapping @RequestBody(将请求体转为java对象)
- 2022.10.5
HttpMediaTypeNotAcceptableException 原因:客户端请求期望响应的媒体类型与服务器响应的媒体类型不一致造成的 如客户端请求:
Accept:Application/json
而服务器响应其他类型 解决方法:
- 在Controller类上加上注解
@RestController 或者在方法上加上@ResponseBody - 如果是自定义了全局异常处理器的话,加上
@RestControllerAdvice - 如果还不行的话,看看有没有对上面类所在包进行扫描,别问,问就是找了大半天,发现spingboot默认自动扫描apingbootApplication类所在包下所有类,但没起作用,最后使用
@SpringBootApplication(scanBasePackages = {"com.study.usercenter"}) 指定扫描的包
|