错误处理记录

SpringBoot


Unknown    pom.xml   Maven Configuration Problem
未知的错误Maven Configuration Problem,解决办法:

在pom.xml中添加如下标签,然后Maven -> Update Project

<properties>
        <java.version>1.8</java.version>
        <maven-jar-plugin.version>3.0.0</maven-jar-plugin.version>
</properties>

Description:

The bean 'bookRepository', defined in null, could not be registered. A bean with that name has already been defined in null and overriding is disabled.

翻译:无法注册用null定义的bean“bookRepository”。具有该名称的bean已经在null中定义,并且禁用了覆盖。

解决办法:

配置文件.yml中添加:spring.main.allow-bean-definition-overriding=true

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

未能配置数据源:未指定“url”属性,无法配置嵌入的数据源。

原因:无法确定合适的驱动程序类

解决办法:

@SpringBootApplication(exclude= {DataSourceAutoConfiguration.class})

注解使用错误

权限控制项目中,用户拥有多个角色,可以用上面的注解关联,

JpaRepository查询的时候,在User对象中会返回roleList,同样,Role对象中会返回userList,造成死循环,返回json数据时会报错:

Could not write JSON: Infinite recursion (StackOverflowError); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Infinite recursion (StackOverflowError) (through reference chain: 

解决办法就是在roleList上加上注解@JsonBackReference

父子项目打包出错

Non-resolvable parent POM for com.example:demo:1.0: Failure to find com.base:springboot-myexample:pom:3.0 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced and 'parent.relativePath' points at no local POM @ line 5, column 13

子项目使用mvn clean或install,错误提示找不到父pom,需要指定正确的父pom路径

打包错误2

打包的项目引用了 父模块的子模块,打包出现找不到类。

感谢:maven模块化项目总共模块相互引用打包失败问题_冰雪Love齐迹的博客-CSDN博客_maven引入其他模块失败

子模块去掉spring-boot-maven-plugin插件(父模块的这个插件也需要去掉),然后install 再重新打包 ok

文件上传导入异常

异常日志:

org.apache.tomcat.util.net.NioEndpoint   : Error running socket processor

java.io.UncheckedIOException: Cannot delete C:\Users\ytlz-admin\AppData\Local\Temp\tomcat.6069.8669546999177605182\work\Tomcat\localhost\ROOT\upload_f7de41bd_438e_4186_9d39_bd73ad06dbed_00000000.tmp

此异常是InputStream 退出时,删除临时文件失败导致;

网上的解决办法,调用close()方法,可是没办法解决我的问题。

经过几个小时的时间,发现是注解@ApiOperation导致的,也不知道什么原因。

一段时间后...发现最近是切面日志保存,对MultipartFile参数转成json字符串时异常了,导致文件没有关闭。

mybatis plus

自定义xml异常问题

版本号、可以自动更新表结构
<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-boot-starter</artifactId>
    <version>3.5.0</version>
</dependency>
<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-generator</artifactId>
    <version>3.5.0</version>
</dependency>
<!--create table-->
<dependency>
    <groupId>com.gitee.sunchenbin.mybatis.actable</groupId>
    <artifactId>mybatis-enhance-actable</artifactId>
    <version>1.5.0.RELEASE</version>
    <exclusions>
        <exclusion>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-annotation</artifactId>
        </exclusion>
    </exclusions>
</dependency>

使用自定义xml sql访问异常

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.example.modules.mapper.SysUserMapper.selectByPrimaryKey

注:3.3.1.tmp 非自动创建表的模块,没有此问题。

解决办法:

    <build>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>com/example/modules/mapper/*Mapper.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
        </resources>
    </build>

配置xml资源路径,尝试配置在resources中失败,先这样解决了。

webSocket自动断开

客户端一直在发送消息,包括心跳检测等消息,可是服务端每隔半分钟就会自动断开,

查了好久,原因是服务端也需要返回消息给客户端,在心跳检测中返回收到消息就解决了。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

进击的rookie

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值