1、使用nacos配置中心,需要将配置文件名称改为bootstrap.yml,否则会报:
Could not resolve placeholder ‘info.name‘ in value "${info.name}"
2、2021后的spring cloud版本需要添加spring-cloud-starter-bootstrap依赖,否则会报:
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
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
3、nacos配置
spring: cloud:nacos:discovery:server-addr: http://127.0.0.1:8848 # nacos注册地址group: xgenamespace: 3ecaa9c7-8eff-4a39-995f-cc7fafe649 # 对应nacos的命名空间idconfig:server-addr: http://127.0.0.1:8848 # nacos注册地址group: xgenamespace: 3ecaa9c7-8eff-4a39-995f-cc7fafe649 # 对应nacos的命名空间idprefix: project-configfile-extension: yaml