2020-09-27

问题描述:代码编译不通过,出Error creating bean with name '***Controller’异常

**解决BUG** **Error creating bean with name '***Controller'** **Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1**
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-09-27 21:39:49.780 ERROR 7212 --- [           main] o.s.boot.SpringApplication               : Application run failed
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name .....   
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1     

原因分析:

问题的分析:
Error creating bean with name

1.clean-install
2.检查@service, @Controller注解
3.检查是否扫描包
4.查看包名是否写错
5.尝试重启idea(这货有时会发呆)
经过上述分析,没能查出我的错误,最会一个点没分析那就是实体类了,于是检查实体类.

/**
 * @program: changgou_parent
 * @description:shop_*
 * @author: Mr.Z
 * @create: 2020-09-27 15:35
 **/
@Table(name="tb_category_brand")
public class CategoryBrand implements Serializable {
    @Id
    private int shop_categoryId;
    @Id
    private int shop_brandId;

看到这里 突然想起来自己用到了通用mapper 而通用mapper源码如下

public interface Mapper<T> extends
        BaseMapper<T>,
        ExampleMapper<T>,
        RowBoundsMapper<T>,
        Marker {

}
事情变得清晰起来了!
于是将int类型改为包装类Integer 重启idea ,编译通过,问题解决!!

解决方案:

将entry实体类int类型 改为Integer

拓展知识:
包装类和基本类型区别
1.包装类可以自动拆箱装箱
2.包装类可以为null值
3.包装类可以用于泛型
4.包装类是基本类型的包装 所以基本类型的性能会更优
5.包装类相对于基本类型更加符合java 面向对象的思想.

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值