错误处理记录

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

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

感谢:https://blog.csdn.net/liqi_q/article/details/80557157

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

Guess you like

Origin blog.csdn.net/qq_36100599/article/details/100729312