java异常

1.原因

1.1造成原因

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'categoryDao' defined in file [D:\programme\java\ssm_ly\ssm_dao\target\classes\com\czxy\CategoryDao.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [tk/mybatis/mapper/autoconfigure/MapperAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [com/alibaba/druid/spring/boot/autoconfigure/DruidDataSourceAutoConfigure.class]: Invocation of init method failed; nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

1.2分析原因

引起的:org.springframework.beans.factory。UnsatisfiedDependencyException:在文件[D: programme\java\ssm_ly\ssm_dao\目标\类\com\czxy\ categoryDao]中创建名为'categoryDao'的bean时出现错误。类]:通过bean属性'sqlSessionFactory'表示的不满意依赖;嵌套异常是org.springframework.beans.factory。UnsatisfiedDependencyException:创建在类路径资源中定义名为“sqlSessionFactory”的bean时出错。类]:通过方法'sqlSessionFactory'参数0表示的未满足依赖;嵌套异常是org.springframework.beans.factory。BeanCreationException:创建在类路径资源中定义名为“dataSource”的bean时出现错误。init方法调用失败;嵌套异常是com.mysql.jdbc. excepators .jdbc4。通信链接失败

2.解决方法

解决方案

问题描述 

1.可能是实体类对应不上数据库

 

例如

@Column(name = "category_id")
private int  category_id;  //分类id

解决:

_  驼峰式名少出现实体类改成categoryId 。

 

 

问题描述 

2.实体类找不到数据库 (项目初始化不了)

 

解决:

方案1

方案2

方案3:

方案4:查看数据库服务是否开启

 

 

目录

1.原因

2.解决方法


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值