报错:
org.springframework.boot.context.config.InvalidConfigDataPropertyException: Property 'spring.profiles.active' imported from location 'class path resource [application-test.yml]' is invalid in a profile specific resource [origin: class path resource [application-test.yml] from app.jar - 9:13]
解决:
步骤 1:检查并修改 application-test.yml
确认 application-test.yml 文件中不存在 spring.profiles.active 属性。
步骤 2:在 application.yml 中指定激活的配置文件
在 application.yml 里添加或者修改 spring.profiles.active 属性:
spring:
profiles:
active: test
spring 2.4 +版本使用
spring:
profiles:
active:
on-profile: test
步骤 3:重新构建并启动服务
使用 docker-compose 重新构建并启动服务:
docker-compose -f docker-compose-test.yml up --build
如果还不行,那就删除镜像
先删除容器
docker ps -a
docker rm <容器ID/名称>
再删除镜像
docker images
docker rmi xxxxx
通过以上步骤,你应该能够解决在特定配置文件中使用 spring.profiles.active 属性导致的错误,从而正常启动服务。