JAVA常见错误

java.lang.IndexOutOfBoundsException: Index: 1, Size: 1

越界错误,这里的错误指数组或列表长度为1 但是下标也到了1 所以导致错误。因此 Index size后面的值可能根据实际情况不同。新手常犯

Caused by: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias ‘XXXXX’. Cause: java.lang.ClassNotFoundException: Cannot find class:XXXXX

springboot项目中 mybatis的xml文件引发的错误,错误提示为找不到 EngyHandelSvg 类
原因:
是因为在编写mapper.xml文件时的 parameterType = “ XXXX” parameterType直接等于类名,导致在复杂的情况下,mybatis无法找到该类,因此需要给它加上全路径
解决方案如下:

parameterType="com.central.system.vo.XXXX"

此处的xxxx为实际类名

Parameter 1 of constructor in com.central.system.service.impl.HandelSvgServiceImpl required a bean of type ‘java.lang.String’ that could not be found…
Parameter 1 of constructor in com.central.system.service.impl.HandelSvgServiceImpl required a bean of type 'java.lang.String' that could not be found.


Action:

Consider defining a bean of type 'java.lang.String' in your configuration.

此错误提示的大概意思是在com.central.system.service.impl.XXXX这个类的构造过程中参数1(也就是第二个参数)在bean注入时找不到,它的类型是String
看错误代码如下:
在这里插入图片描述
在这里插入图片描述
解决方案:
在这里插入图片描述
大多人常犯的错误为Mapper或service注入失败:

Description:

Parameter 0 of constructor in com.central.system.service.impl.DefineExcelServiceImpl required a bean of type 'com.central.system.mapper.DefineExcelMapper' that could not be found.


Action:

Consider defining a bean of type 'com.central.system.mapper.DefineExcelMapper' in your configuration.

检查 com.central.system.mapper.DefineExcelMapper 是否加了@mapper注解

@Mapper
public interface DefineExcelMapper 
Spring Security报错

报错信息:

Error creating bean with name 'springSecurityFilterChain' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]:
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.Filter]:
 Factory method 'springSecurityFilterChain' threw exception; 
 nested exception is java.lang.IllegalStateException: 
 permitAll only works with HttpSecurity.authorizeRequests()

重点语句:permitAll only works with HttpSecurity.authorizeRequests()
意思是说 permitAll仅适用于HttpSecurity.authorizeRequests()
查看配置代码中http后面的是不是写错了 错误示例如下

http.authorizeHttpRequests()
.antMatchers("/oauth/**","/login/**","/logout/**").permitAll()
.anyRequest().authenticated()
.and()
//表单认证全部放行
.formLogin().permitAll();

解决方案:将authorizeHttpRequests()替换成authorizeRequests()

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值