spring boot 错误记录

本文解析了SpringBoot项目中常见的错误,如依赖注入失败、SQL语法错误、索引越界、验证约束缺失等,并提供了详细的解决方案,包括正确使用注解、检查数据库表结构、完善实体类构造函数及正确应用数据校验。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

错误提示:

 Unsatisfied dependency expressed through field 'baseMapper'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'io.renren.modules.sys.dao.excelDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

解决办法:应为dao层缺少注解@Mapper导致的

错误提示:

org.springframework.jdbc.BadSqlGrammarException: 
### Error querying database.  Cause: java.sql.SQLSyntaxErrorException: Table 'renren_security.excel_entity' doesn't exist
### The error may exist in io/renren/modules/sys/dao/excelDao.java (best guess)
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: SELECT  name,sex,birthday  FROM excel_entity
### Cause: java.sql.SQLSyntaxErrorException: Table 'renren_security.excel_entity' doesn't exist
; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: Table 'renren_security.excel_entity' doesn't exist

解决办法:在没有给entity 注入table_name(),注解时。是不是默认去找实体名_entity.

错误提示:

Cause: java.lang.IndexOutOfBoundsException: Index: 3, Size: 3

原因分析:数组越界导致。

Error querying database.  Cause: java.lang.IndexOutOfBoundsException: Index: 3, Size: 3

原因分析:idex:3 表示的是第三个构造函数参数出现问题。我的是多写了一个参数,
在百度中也会有应为没有提供构造函数出现的同样的问题(@data 注解没不会添加构造函数)。如果项目中使用了mybatisplus和lombok ,
**解决:**在实体类中添加注解:@AllArgsConstructor //全参构造函数
@NoArgsConstructor //无参构造函数

No validator could be found for constraint 'javax.validation.constraints.NotBlank' 
validating type '

**原因分析:**项目中使用的校验注解所支持的数据类型与实体中字段的类型不符合。
例如:
在这里插入图片描述
在Integer类型的字段上使用@NotEmpty,@NotEmpty支持的是字符串类型字段,这样子使用肯定是会报错的。

错误提示:
在这里插入图片描述
**原因分析:**在RequstMapping中存在两个同名的value

错误信息:

Exception encountered during context initialization - cancelling
 refresh attempt: 
 org.springframework.context.ApplicationContextException: Unable to 
 start web server; nested exception is 
 org.springframework.boot.web.server.WebServerException: Unable to
  start embedded Tomcat

**原因分析:**包冲突,可能是poml文件有问题

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值