- Mybatis逆向工程生成代码报错
Public Key Retrieval is not allowed
# 在配置文件和逆向工程url链接中加入
allowPublicKeyRetrieval=true
- SpringBoot引用Eureka导致返回结果由json变为xml解决方案
在@GetMapping 后加入produces = MediaType.APPLICATION_JSON_UTF8_VALUE
即可
@GetMapping(value = "/consumer/payment/get/{id}",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
- springboot启动web项目报异常:
This application has no explicit mapping for /error, so you are seeing this as a fallback
1. 原因可能是controller层包的位置放置错误,没有放到com.ssm.springboot包下面
2. 地址输入错误
3. 添加@SpringBootApplication(scanBasePackages="controller")指定你的controller的位置,指定加载来解决问题
- mybatis-plus学习文件好久没用了 ,今天翻开启动一下报错:
java.lang.IllegalArgumentException: XML fragments parsed from previous mappers does not contain value
在项目中target文件下找到mapper.xml这个文件,删除后重新启动测试代码,问题解决。
- springboot项目正常启动但刷新swagger控制台会报
java.lang.NumberFormatException: For input string: ""
在需要提交的参数以json的形式提交的前面加入 @RequestBody(required = false) 以表示次参数可以为空,并将提交形式改为post提交即:
@PostMapping("findQueryPage/{current}/{limit}")
@ApiOperation("条件查询分页")
@PostMapping("findQueryPage/...")
public Result findQueryPage(...
@ApiParam(name = "teacherVo", value = "查询对象", required = false)
@RequestBody(required = false) TeacherQueryVo teacherQueryVo) {
...
return Result.ok(pageModel);
}
}
- 在前后端分离项目中前端调用后端接口报错:
org.springframework.web.method.annotation.MethodArgumentTypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'long'; nested exception is java.lang.NumberFormatException: For input string:"null" (/"")
1.这个错误提示很坑,提示很不明显遇到这个问题就仔细核对自己的代码吧
2.接口返回值为null
- 在写了mapper文件后与运行报错
org.[apache](https://so.csdn.net/so/search?q=apache&spm=1001.2101.3001.7020).ibatis.binding.BindingException: Invalid bound statement (not found): xx.xx.xx.mapper.xxMapper.xx
- maven加载机制
maven默认情况下,在src-main-java目录下面,maven只会加载java类型文件,其他类型文件不会加载的
- 解决办法:
1.直接复制mapper文件到target目录下
2.把xml文件放到resource目录下
3.通过配置文件自动加载:(推荐使用)
3.1 pom.xml
3.2 application.properties
pom.xml添加
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.yml</include>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes> <include>**/*.yml</include>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
application.properties添加
mybatis-plus.mapper-locations=classpath:com/ssm/ggkt/vod/mapper/xml/*.xml