有关使用最新版springcloud alibaba启动微服务无法从nacos中获取数据库配置的问题

    <spring.boot.version>3.3.5</spring.boot.version>
    <!-- Spring Cloud 2023.x 版本 -->
    <spring.cloud.version>2023.0.3</spring.cloud.version>
    <!-- Spring Cloud Alibaba 版本 -->
    <alibaba.cloud.version>2023.0.1.3</alibaba.cloud.version>

这是我使用的spring各个框架相关的版本,我先启动了我的nacos注册中i性能,然后当我的项目启动其中一个微服务的时候,会报如下错误:
2025-11-08T14:43:53.072+08:00 WARN 3624 --- [mainServer] [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sysTestController' defined in file [D:\Code\SpringCloud-New-BackEnd\mainServer\target\classes\com\sys\apply\controller\SysTestController.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'sysConfigServiceImpl' defined in file [D:\Code\SpringCloud-New-BackEnd\mainServer\target\classes\com\sys\apply\service\impl\SysConfigServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'sysConfigMapper' defined in file [D:\Code\SpringCloud-New-BackEnd\mainServer\target\classes\com\sys\apply\mapper\SysConfigMapper.class]: Cannot resolve reference to bean 'sqlSessionTemplate' while setting bean property 'sqlSessionTemplate'
2025-11-08T14:43:53.073+08:00 INFO 3624 --- [mainServer] [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2025-11-08T14:43:53.085+08:00 INFO 3624 --- [mainServer] [ main] .s.b.a.l.ConditionEvaluationReportLogger :

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2025-11-08T14:43:53.098+08:00 ERROR 3624 --- [mainServer] [ main] 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).

也就是无法读取数据库配置的错误,但是我已经在nacos中写了数据库的配置,如果换成之前springboot2.x的版本则会正常,但是用新项目(也就是当前这个项目,springboot3.x版本的)就会出现无法从nacos中读取数据库配置的问题

  这里附上我的bootstrap.yaml:

spring配置

spring:
application:
name: mainServer
cloud:
nacos:

  # 用nacos做配置中心
  config:
    server-addr: 127.0.0.1:8848
    file-extension: yaml
    username: nacos
    password: szy89545

import-check:

enabled: false # 禁用导入检查

extension-configs:

- data-id: mainServer.yaml

group: DEFAULT_GROUP

refresh: true

  discovery:
    server-addr: ${spring.cloud.nacos.config.server-addr}
    username: ${spring.cloud.nacos.config.username}
    password: ${spring.cloud.nacos.config.password}

server:
address: 0.0.0.0
port: 8090
servlet:
encoding:
charset: UTF-8
force: true
enabled: true
有没有大佬知道这是怎么回事

展开
收起
游客hrknprgnx2smc 2025-11-08 15:32:46 26 分享 版权
0 条回答
写回答
取消 提交回答

为微服务建设降本增效,为微服务落地保驾护航。

还有其他疑问?
咨询AI助理