美文网首页Java
数据源没有配置导致报错

数据源没有配置导致报错

作者: 花伤情犹在 | 来源:发表于2021-12-04 13:00 被阅读0次

Druid德鲁伊阿里巴巴的数据库连接池

<dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>1.2.8</version>
        </dependency>

如果没有配置数据源默认会报错:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSource': Unsatisfied dependency expressed through field 'basicProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'spring.datasource-org.springframework.boot.autoconfigure.jdbc.DataSourceProperties': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.autoconfigure.jdbc.DataSourceProperties]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/dao/DataAccessException

Mybatis 增强工具包

只做增强不做改变,简化CRUD操作

        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.2.0</version>
        </dependency>

如果没有配置数据源会报错:

Consider the following:
    If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
    If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).

翻译:

请考虑以下事项: 如果您想要一个嵌入式数据库(H2、HSQL 或 Derby),请将其放在类路径中。如果您有要从特定配置文件加载的数据库设置,您可能需要激活它(当前没有配置文件处于活动状态)。

nacos配置中心

 <dependency>
  <groupId>com.alibaba.cloud</groupId>
  <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>

如果没有配置配置源地址

spring.cloud.nacos.config.server-addr=127.0.0.1:8848

会报以下错:

com.alibaba.nacos.api.exception.NacosException: java.lang.reflect.InvocationTargetException
    at com.alibaba.nacos.api.config.ConfigFactory.createConfigService(ConfigFactory.java:45) ~[nacos-api-1.1.1.jar:na]

相关文章

网友评论

    本文标题:数据源没有配置导致报错

    本文链接:https://www.haomeiwen.com/subject/sdbvxrtx.html