<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:
application:
name: mainServer
cloud:
nacos:
# 用nacos做配置中心
config:
server-addr: 127.0.0.1:8848
file-extension: yaml
username: nacos
password: szy89545
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
有没有大佬知道这是怎么回事
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。