java异常

    科技2022-08-02  114

    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.解决方法


    Processed: 0.008, SQL: 8