pom.xml配置 :
org.springframework.boot spring-boot-maven-pluginorg.apache.maven.plugins maven-surefire-plugin2.20 true src/main/resources true dev false2100 budget-boot-dev 3e1110da-1111-4cff-96c8-d51212415bdc 192.168.3.131:8848 test false2200 budget-boot-test 3e1110da-1111-4cff-96c8-d51212415bdc 192.168.3.131:8848
bootstrap.yml中部分代码示例:
server:
port: @server.port@
compression:
enabled: true
spring:
application:
name: @spring.application.name@
cloud:
nacos:
discovery:
namespace: @nacos.config.namespace@
server-addr: @nacos.config.server-addr@
username: nacos
password: nacos
config:
namespace: @nacos.config.namespace@
server-addr: @nacos.config.server-addr@
username: nacos
password: nacos
file-extension: yml
shared-configs:
- dev-boot.yml
配置完成后,在右侧的Maven会出现Profiles:
spring cloud 项目,注册中心nacos。
以上是完整配置。
若出现:
Do not use @ for indentation 异常
这需要在
src/main/resources true
经测试发现,如果执行了maven-clean,在启动项目,一样会报错:Do not use @ for indentation 。
后来查到一个办法:maven-clean-compile, 执行清除、编译,在启动。就没问题。因为编译的时候配置文件里的值会被替换掉,但是这样操作很麻烦。
第二个办法:
org.apache.maven.plugins maven-resources-plugin@ false
再增加一个插件插件配置,这样就好了。在上面配置的基础上加上此配置
发现以上配置有时候不起作用,然后执行maven-clean继续启动也失败。
最后在pom.xml 点击右键选择maven-Reimport:
再启动,正常
参考:
springboot yml配置文件使用@project.xxxx@ 启动报错Do not use @ for indentation_jyyy1990的博客-CSDN博客



