java - SpringBoot 抛出异常 InvalidStatementException,如何解决?
问题描述
我在 的 URL 中定义了一个 API /getAppInfo
,它的参数只有一个这样的 ID:
@ResponseBody
@RequestMapping("/getAppInfo")
public ResultResponse getAppInfo(String id) {
ResultResponse result = new ResultResponse();
String appName = uploadedFile.getAppInfo(id);
result.setResult(appName);
return result;
}
uploadedFile
是 Interface 的一个对象,IUploadedFileMapper
这个 Mapper 反映了一个名为 的 MyBatis 映射器UploadedFileMapper.xml
。
然后我将以下代码写入IUploadedFileMapper.java
:
public String getAppInfo(String id);
之后,我将以下代码写入UploadedFileMapper.xml
:
<select id="getAppInfo" parameterType="java.lang.String" resultType="java.lang.String">
select tb.name from table tb where tb.id = #{id} and tb.business_sub_type = 'APP';
</select>
当我测试这个 WebAPI 时,spring-boot 告诉我:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): example.cn.dao.IUploadedFileMapper.getAppInfo
解决方案
您不需要table
在 SQL 选择查询中
select tb.name from table tb
=>
select tb.name from tb
推荐阅读
- javascript - 手风琴 .glyphicon-chevron-up 和 .glyphicon-chevron-down 不起作用
- scala - Shapeless - 泛型上下文中的泛型
- java - TestNG 参数化:将浏览器类型传递给基类时出现 NullPointerException
- angular - 解析 Angular 通用服务中的通用参数
- bash - 我如何循环浏览一定数量的文件夹
- azure - Set-Variable 策略:不允许表达式返回类型
- python - 如何从其二进制代码加载图像
- node.js - node-red 使用多个来源构建 http post 请求
- php - PHP多维数组到两列HTML表
- gcc - LD:链接描述文件中的 ALIGN 与 SUBALIGN