【Java】异常合集

2 篇文章 0 订阅
1 篇文章 0 订阅

1.BindingException

org.apache.ibatis.binding.BindingException: 
Type interface com.jcli.dao.UserDao is not known to the MapperRegistry.

1.SqlMapConfig.xml里面路径未改。

2.SqlMapConfig.xml的mappers没有告诉mybatis映射文件位置。

<mappers>
        <mapper resource="com/jcli/dao/UserDao.xml"/>
        <mapper resource="com/jcli/dao/UserDao02.xml"/>
    </mappers>

3.映射文件名写错 


org.apache.ibatis.binding.BindingException: 
Invalid bound statement (not found): 
com.jcli.dao.UserDao.findAll

2.NullPointerException

java.lang.NullPointerException

1.多new了一个工厂对象,导致地址不一样

3.ReflectionException

org.apache.ibatis.exceptions.PersistenceException: 
Caused by: org.apache.ibatis.reflection.ReflectionException: 
Could not set property 'address02' of 'class com.jcli.bean.User' with value '北京' Cause:
 org.apache.ibatis.reflection.ReflectionException: 
There is no setter for property named 'address02' in 'class com.jcli.bean.User'

1.自己写了个不存在的属性

4.BeanCreationException

Caused by: 
org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'userService' defined in file [D:\jclicode\04\23\springboot\springboot04-junit\target\classes\com\jcli\service\UserService.class]: 
Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: 
Failed to instantiate [com.jcli.service.UserService]: 
Specified class is an interface

1. 配置文件中没有写端口号,加上就运行了。

server:
  port: 8888
#spring data source数据源配置
spring:
  datasource:
#    driver-class-name: com.mysql.jdbc.Driver
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost/jcli_springboot?useUnicode=true&characterEncoding=UTF-8
    username: root
    password: admin

无解问题,重写又可以

6.ConnectException

java.net.ConnectException: 
Connection refused: 
no further information

 1.redis服务端没有启动

5.InvalidConnectionAttributeException

com.mysql.cj.exceptions.InvalidConnectionAttributeException: 
The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_202]
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_202]
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_202]
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_202]

 配置文件加:

default-time-zone = '+8:00'

 url接:ok

&serverTimezone=UTC

持续更新中~~~

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值