前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >bug问题总结

bug问题总结

作者头像
shaoshaossm
发布2022-12-26 15:34:37
5460
发布2022-12-26 15:34:37
举报
文章被收录于专栏:Java啊
  • Mybatis逆向工程生成代码报错 Public Key Retrieval is not allowed

properties

代码语言:javascript
复制
# 在配置文件和逆向工程url链接中加入
allowPublicKeyRetrieval=true
  • SpringBoot引用Eureka导致返回结果由json变为xml解决方案
问题演示
问题演示

问题演示

在@GetMapping 后加入produces = MediaType.APPLICATION_JSON_UTF8_VALUE 即可

java

代码语言:javascript
复制
@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

java

代码语言:javascript
复制
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

java

代码语言:javascript
复制
在项目中target文件下找到mapper.xml这个文件,删除后重新启动测试代码,问题解决。
  • springboot项目正常启动但刷新swagger控制台会报java.lang.NumberFormatException: For input string: ""

java

代码语言:javascript
复制
在需要提交的参数以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" (/"")

java

代码语言:javascript
复制
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

java

代码语言:javascript
复制
- maven加载机制
    maven默认情况下,在src-main-java目录下面,maven只会加载java类型文件,其他类型文件不会加载的
- 解决办法:
    1.直接复制mapper文件到target目录下
    2.把xml文件放到resource目录下
    3.通过配置文件自动加载:(推荐使用)
    	3.1 pom.xml
    	3.2 application.properties

pom.xml添加

xml

代码语言:javascript
复制
<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添加

properties

代码语言:javascript
复制
mybatis-plus.mapper-locations=classpath:com/ssm/ggkt/vod/mapper/xml/*.xml
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022-04-03,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档