Home > OS >  SpringBoot profiles with Gradle vs cloud
SpringBoot profiles with Gradle vs cloud

Time:11-18

I have some problem with starting microservice with cloud config on local machine: In application.yml:

spring:
  application:
    name: my_servie
  config:
    import: 'configserver:'
  profiles:
    group:
      env-prod-pg: postgres,log

I create application-local.yml, where add:

spring:
  application:
    name: mc-service-logistics-v2
  config:
    import: 'optional:configserver:'

and some other config updates, in build.gradle I add:

tasks.register("bootRunLocal") {
    group = "application"
    description = "Runs the Spring Boot application with the local profile"
    doFirst {
        tasks.bootRun.configure {
            systemProperty("spring.profiles.active", "local")
        }
    }
    finalizedBy("bootRun")
}

but when I try to start app with gradle bootRunLocal I caught error: Caused by: org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://localhost:8888/my-service/local": Connection refused; nested exception is java.net.ConnectException: Connection refused

If I understand- application still want to use cloud config and can't start. If I comment spring.config.import in application.yml- aplication started without any problem.

How to solve this problem? I don't want to push to repo my local config again)

CodePudding user response:

Well, I create to application-.yml and application.yml ,where store current profile:

spring:
  profiles:
    active: prod
  • Related