报错:

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 属性导致的错误,从而正常启动服务。

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐