使用nacos配置数据库连接报错


2021-01-06 15:44:30.570  INFO 14788 --- [  restartedMain] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2021-01-06 15:44:30.657  INFO 14788 --- [  restartedMain] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-01-06 15:44:30.661 ERROR 14788 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   :

***************************
APPLICATION FAILED TO START
***************************

Description:

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

Reason: Failed to determine a suitable driver class


Action:

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).

你倒是把你的配置截图出来啊.....

spring:
    datasource:
        type: com.alibaba.druid.pool.DruidDataSource
        driver-class-name: com.mysql.jdbc.Driver
        url: jdbc:mysql://123.56.132.14:3306/zbfwpt?useUnicode=false&useSSL=true&characterEncoding=utf8
        username: root
        password: one
        initial-size: 5
        max-active: 50
        max-wait: 3000
        use-unfair-lock: true
        pool-prepared-statements: false
        filters: stat,log4j,wall
        validation-query: select 1
        validation-query-timeout: 3000
        test-on-borrow: true
        test-on-return: false
        test-while-idle: true
        time-between-eviction-runs-millis: 5000
    redis:
        host: 127.0.0.1
        port: 6379
        database: 1
        jedis:
            pool:
                max-active: 50
                max-wait: 3000
                max-idle: 20
                min-idle: 2 
        timeout: 5000 
config:
    jwt:
        secret: abcdefg1234567
        expire: 180000
        header: Authorization
    signAuth:
        KEY: wzgs@1234    

nacos 的配置项还有你在主站的截图发下。

 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-01-06 16:10:33.369 ERROR 16484 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

Reason: Failed to determine a suitable driver class


Action:

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).


Process finished with exit code 0
 

配置项?

 

 

 

检查下自己nacos里面对数据源的配置,报错信息就是找不到合适的url,没映射到,你仔细查看一下吧

只有这个模块不能,别的模块也是用的相同的配置

那就更方便了,检查 bootstrap文件

#bootstrap 优先于 applicaiton 配置文件
spring:
  application:
    name: lxejd-service
  main:
    allow-bean-definition-overriding: true
  cloud:
    nacos:
      discovery:
        server-addr: 127.0.0.1:8848
        namespace: 88747fe2-193f-4a21-a71b-0ce9bef6dca5
      config:
        server-addr: 127.0.0.1:8848
        file-extension: yaml #指定yaml格式配置
        #${prefix}-${spring.profiles.active}.${file-extension} 公式
        #nacos-config-client-dev.yaml
        namespace: 88747fe2-193f-4a21-a71b-0ce9bef6dca5

 

你这分组啥的怎么配的,有点没看懂

 

可以参考这个:https://blog.csdn.net/qq_16498553/article/details/111659478

楼主,怎么解决的,一模一样的问题

同问

同问