diff --git a/api-gateway/src/main/resources/application-development-docker.yml b/api-gateway/src/main/resources/application-development-docker.yml index ee67a453..4169ac87 100644 --- a/api-gateway/src/main/resources/application-development-docker.yml +++ b/api-gateway/src/main/resources/application-development-docker.yml @@ -1,8 +1,4 @@ spring: - cloud: - consul: - host: maf.consul-service-registry.development - port: 8500 zipkin: base-url: http://maf.zipkin.development:9411 devtools: diff --git a/api-gateway/src/main/resources/application-development-local.yml b/api-gateway/src/main/resources/application-development-local.yml index 568aa9a1..75064352 100644 --- a/api-gateway/src/main/resources/application-development-local.yml +++ b/api-gateway/src/main/resources/application-development-local.yml @@ -1,8 +1,4 @@ spring: - cloud: - consul: - host: localhost - port: 8500 zipkin: base-url: http://localhost:9411 devtools: diff --git a/api-gateway/src/main/resources/application-production.yml b/api-gateway/src/main/resources/application-production.yml index 23ed5ab3..606c9098 100644 --- a/api-gateway/src/main/resources/application-production.yml +++ b/api-gateway/src/main/resources/application-production.yml @@ -1,8 +1,4 @@ spring: - cloud: - consul: - host: maf.consul-service-registry.production - port: 8500 zipkin: base-url: http://maf.zipkin.production:9411 devtools: diff --git a/api-gateway/src/main/resources/application-stage.yml b/api-gateway/src/main/resources/application-stage.yml index 35e29292..b5ecff93 100644 --- a/api-gateway/src/main/resources/application-stage.yml +++ b/api-gateway/src/main/resources/application-stage.yml @@ -1,8 +1,4 @@ spring: - cloud: - consul: - host: maf.consul-service-registry.stage - port: 8500 zipkin: base-url: http://maf.zipkin.stage:9411 devtools: diff --git a/api-gateway/src/main/resources/application-test.yml b/api-gateway/src/main/resources/application-test.yml index 7c3bdca1..e451cb7e 100644 --- a/api-gateway/src/main/resources/application-test.yml +++ b/api-gateway/src/main/resources/application-test.yml @@ -1,8 +1,4 @@ spring: - cloud: - consul: - host: maf.consul-service-registry.test - port: 8500 zipkin: base-url: http://maf.zipkin.test:9411 devtools: diff --git a/api-gateway/src/main/resources/application.yml b/api-gateway/src/main/resources/application.yml index c36a9b4c..a96b5127 100644 --- a/api-gateway/src/main/resources/application.yml +++ b/api-gateway/src/main/resources/application.yml @@ -4,8 +4,6 @@ server: uri-encoding: @project.build.sourceEncoding@ spring: - application: - name: @project.artifactId@ profiles: active: @env@ mvc: @@ -18,21 +16,10 @@ spring: probability: 1.0 cloud: consul: - config: - enabled: true - prefix: config - # `default-context` should be equal to Spring application name - default-context: ${spring.application.name} - profile-separator: "-" - format: YAML - data-key: "data" - watch: - enabled: true - delay: 1000 discovery: register: true - instance-id: ${spring.cloud.client.hostname}-${spring.cloud.client.ip-address}-${server.port}-${spring.application.name} - service-name: ${spring.application.name} + instance-id: ${spring.cloud.client.hostname}-${spring.cloud.client.ip-address}-${server.port}-@project.artifactId@ + service-name: @project.artifactId@ port: ${server.port} prefer-ip-address: true ip-address: ${spring.cloud.client.ip-address} diff --git a/api-gateway/src/main/resources/bootstrap.yml b/api-gateway/src/main/resources/bootstrap.yml new file mode 100644 index 00000000..b62087da --- /dev/null +++ b/api-gateway/src/main/resources/bootstrap.yml @@ -0,0 +1,18 @@ +spring: + application: + name: @project.artifactId@ + cloud: + consul: + host: "should-be-passed-by-java-opts" + port: 8500 + config: + enabled: true + prefix: config + # `default-context` should be equal to Spring application name + default-context: @project.artifactId@ + profile-separator: '::' + format: YAML + data-key: "data" + watch: + enabled: true + delay: 1000 diff --git a/auth-center/src/main/resources/application-development-docker.yml b/auth-center/src/main/resources/application-development-docker.yml index 6cd54086..635ac732 100644 --- a/auth-center/src/main/resources/application-development-docker.yml +++ b/auth-center/src/main/resources/application-development-docker.yml @@ -1,8 +1,4 @@ spring: - cloud: - consul: - host: maf.consul-service-registry.development - port: 8500 zipkin: base-url: http://maf.zipkin.development:9411 devtools: diff --git a/auth-center/src/main/resources/application-development-local.yml b/auth-center/src/main/resources/application-development-local.yml index 9ead61ef..efb02486 100644 --- a/auth-center/src/main/resources/application-development-local.yml +++ b/auth-center/src/main/resources/application-development-local.yml @@ -1,8 +1,4 @@ spring: - cloud: - consul: - host: localhost - port: 8500 zipkin: base-url: http://localhost:9411 devtools: diff --git a/auth-center/src/main/resources/application-production.yml b/auth-center/src/main/resources/application-production.yml index 8ef747e1..c28664fa 100644 --- a/auth-center/src/main/resources/application-production.yml +++ b/auth-center/src/main/resources/application-production.yml @@ -1,8 +1,4 @@ spring: - cloud: - consul: - host: maf.consul-service-registry.production - port: 8500 zipkin: base-url: http://maf.zipkin.production:9411 devtools: diff --git a/auth-center/src/main/resources/application-stage.yml b/auth-center/src/main/resources/application-stage.yml index aab171a7..7037108c 100644 --- a/auth-center/src/main/resources/application-stage.yml +++ b/auth-center/src/main/resources/application-stage.yml @@ -1,8 +1,4 @@ spring: - cloud: - consul: - host: maf.consul-service-registry.stage - port: 8500 zipkin: base-url: http://maf.zipkin.stage:9411 devtools: diff --git a/auth-center/src/main/resources/application-test.yml b/auth-center/src/main/resources/application-test.yml index e2f3353d..500094e3 100644 --- a/auth-center/src/main/resources/application-test.yml +++ b/auth-center/src/main/resources/application-test.yml @@ -1,8 +1,4 @@ spring: - cloud: - consul: - host: maf.consul-service-registry.test - port: 8500 zipkin: base-url: http://maf.zipkin.test:9411 devtools: diff --git a/auth-center/src/main/resources/application.yml b/auth-center/src/main/resources/application.yml index db87c65d..5a274e6a 100644 --- a/auth-center/src/main/resources/application.yml +++ b/auth-center/src/main/resources/application.yml @@ -4,8 +4,6 @@ server: uri-encoding: @project.build.sourceEncoding@ spring: - application: - name: @project.artifactId@ profiles: active: @env@ mvc: @@ -30,21 +28,10 @@ spring: file-size-threshold: 0 cloud: consul: - config: - enabled: true - prefix: config - # `default-context` should be equal to Spring application name - default-context: ${spring.application.name} - profile-separator: "-" - format: YAML - data-key: "data" - watch: - enabled: true - delay: 1000 discovery: register: true - instance-id: ${spring.cloud.client.hostname}-${spring.cloud.client.ip-address}-${server.port}-${spring.application.name} - service-name: ${spring.application.name} + instance-id: ${spring.cloud.client.hostname}-${spring.cloud.client.ip-address}-${server.port}-@project.artifactId@ + service-name: @project.artifactId@ port: ${server.port} prefer-ip-address: true ip-address: ${spring.cloud.client.ip-address} @@ -57,7 +44,6 @@ spring: minIdle: 10 max-active: 20 max-wait: 60000 - time-between-eviction-runs-millis: 10000 min-evictable-idle-time-millis: 600000 max-evictable-idle-time-millis: 900000 validation-query: SELECT 1 @@ -174,7 +160,7 @@ maf: - "/*/v2/api-docs/**" - "/webjars/**" - "/doc.html" - included-package-for-http-api-scan: ${project.property.base-package} + included-package-for-http-api-scan: ${maf.project-property.base-package} # Customize JWT configuration for development environment. jwt: diff --git a/auth-center/src/main/resources/bootstrap.yml b/auth-center/src/main/resources/bootstrap.yml new file mode 100644 index 00000000..b62087da --- /dev/null +++ b/auth-center/src/main/resources/bootstrap.yml @@ -0,0 +1,18 @@ +spring: + application: + name: @project.artifactId@ + cloud: + consul: + host: "should-be-passed-by-java-opts" + port: 8500 + config: + enabled: true + prefix: config + # `default-context` should be equal to Spring application name + default-context: @project.artifactId@ + profile-separator: '::' + format: YAML + data-key: "data" + watch: + enabled: true + delay: 1000 diff --git a/docker/config/auth-center/application.yml b/docker/config/auth-center/application.yml new file mode 100644 index 00000000..9bd9419d --- /dev/null +++ b/docker/config/auth-center/application.yml @@ -0,0 +1 @@ +greeting: "Hello from Consul config center!" diff --git a/exercise-mis/src/main/resources/application-development-docker.yml b/exercise-mis/src/main/resources/application-development-docker.yml index 6cd54086..635ac732 100644 --- a/exercise-mis/src/main/resources/application-development-docker.yml +++ b/exercise-mis/src/main/resources/application-development-docker.yml @@ -1,8 +1,4 @@ spring: - cloud: - consul: - host: maf.consul-service-registry.development - port: 8500 zipkin: base-url: http://maf.zipkin.development:9411 devtools: diff --git a/exercise-mis/src/main/resources/application-development-local.yml b/exercise-mis/src/main/resources/application-development-local.yml index 4fa15488..115ca7ad 100644 --- a/exercise-mis/src/main/resources/application-development-local.yml +++ b/exercise-mis/src/main/resources/application-development-local.yml @@ -1,8 +1,4 @@ spring: - cloud: - consul: - host: localhost - port: 8500 zipkin: base-url: http://localhost:9411 devtools: diff --git a/exercise-mis/src/main/resources/application-production.yml b/exercise-mis/src/main/resources/application-production.yml index 8ef747e1..c28664fa 100644 --- a/exercise-mis/src/main/resources/application-production.yml +++ b/exercise-mis/src/main/resources/application-production.yml @@ -1,8 +1,4 @@ spring: - cloud: - consul: - host: maf.consul-service-registry.production - port: 8500 zipkin: base-url: http://maf.zipkin.production:9411 devtools: diff --git a/exercise-mis/src/main/resources/application-stage.yml b/exercise-mis/src/main/resources/application-stage.yml index b49423a7..4e45ee98 100644 --- a/exercise-mis/src/main/resources/application-stage.yml +++ b/exercise-mis/src/main/resources/application-stage.yml @@ -1,8 +1,4 @@ spring: - cloud: - consul: - host: maf.consul-service-registry.stage - port: 8500 zipkin: base-url: http://maf.zipkin.stage:9411 devtools: diff --git a/exercise-mis/src/main/resources/application-test.yml b/exercise-mis/src/main/resources/application-test.yml index 1a8c98a9..b83acec4 100644 --- a/exercise-mis/src/main/resources/application-test.yml +++ b/exercise-mis/src/main/resources/application-test.yml @@ -1,8 +1,4 @@ spring: - cloud: - consul: - host: maf.consul-service-registry.test - port: 8500 zipkin: base-url: http://maf.zipkin.test:9411 devtools: diff --git a/exercise-mis/src/main/resources/application.yml b/exercise-mis/src/main/resources/application.yml index 9a46a844..59268427 100644 --- a/exercise-mis/src/main/resources/application.yml +++ b/exercise-mis/src/main/resources/application.yml @@ -30,21 +30,10 @@ spring: file-size-threshold: 0 cloud: consul: - config: - enabled: true - prefix: config - # `default-context` should be equal to Spring application name - default-context: ${spring.application.name} - profile-separator: "-" - format: YAML - data-key: "data" - watch: - enabled: true - delay: 1000 discovery: register: true - instance-id: ${spring.cloud.client.hostname}-${spring.cloud.client.ip-address}-${server.port}-${spring.application.name} - service-name: ${spring.application.name} + instance-id: ${spring.cloud.client.hostname}-${spring.cloud.client.ip-address}-${server.port}-@project.artifactId@ + service-name: @project.artifactId@ port: ${server.port} prefer-ip-address: true ip-address: ${spring.cloud.client.ip-address} @@ -171,7 +160,7 @@ maf: - "/*/v2/api-docs/**" - "/webjars/**" - "/doc.html" - included-package-for-http-api-scan: ${project.property.base-package} + included-package-for-http-api-scan: ${maf.project-property.base-package} sftp: client: diff --git a/exercise-mis/src/main/resources/bootstrap.yml b/exercise-mis/src/main/resources/bootstrap.yml new file mode 100644 index 00000000..b62087da --- /dev/null +++ b/exercise-mis/src/main/resources/bootstrap.yml @@ -0,0 +1,18 @@ +spring: + application: + name: @project.artifactId@ + cloud: + consul: + host: "should-be-passed-by-java-opts" + port: 8500 + config: + enabled: true + prefix: config + # `default-context` should be equal to Spring application name + default-context: @project.artifactId@ + profile-separator: '::' + format: YAML + data-key: "data" + watch: + enabled: true + delay: 1000 diff --git a/muscle-mis/src/main/resources/application-development-docker.yml b/muscle-mis/src/main/resources/application-development-docker.yml index 6cd54086..635ac732 100644 --- a/muscle-mis/src/main/resources/application-development-docker.yml +++ b/muscle-mis/src/main/resources/application-development-docker.yml @@ -1,8 +1,4 @@ spring: - cloud: - consul: - host: maf.consul-service-registry.development - port: 8500 zipkin: base-url: http://maf.zipkin.development:9411 devtools: diff --git a/muscle-mis/src/main/resources/application-development-local.yml b/muscle-mis/src/main/resources/application-development-local.yml index 44de1c24..2cc22fdd 100644 --- a/muscle-mis/src/main/resources/application-development-local.yml +++ b/muscle-mis/src/main/resources/application-development-local.yml @@ -1,8 +1,4 @@ spring: - cloud: - consul: - host: localhost - port: 8500 zipkin: base-url: http://localhost:9411 devtools: diff --git a/muscle-mis/src/main/resources/application-production.yml b/muscle-mis/src/main/resources/application-production.yml index 8ef747e1..c28664fa 100644 --- a/muscle-mis/src/main/resources/application-production.yml +++ b/muscle-mis/src/main/resources/application-production.yml @@ -1,8 +1,4 @@ spring: - cloud: - consul: - host: maf.consul-service-registry.production - port: 8500 zipkin: base-url: http://maf.zipkin.production:9411 devtools: diff --git a/muscle-mis/src/main/resources/application-stage.yml b/muscle-mis/src/main/resources/application-stage.yml index aab171a7..7037108c 100644 --- a/muscle-mis/src/main/resources/application-stage.yml +++ b/muscle-mis/src/main/resources/application-stage.yml @@ -1,8 +1,4 @@ spring: - cloud: - consul: - host: maf.consul-service-registry.stage - port: 8500 zipkin: base-url: http://maf.zipkin.stage:9411 devtools: diff --git a/muscle-mis/src/main/resources/application-test.yml b/muscle-mis/src/main/resources/application-test.yml index e2f3353d..500094e3 100644 --- a/muscle-mis/src/main/resources/application-test.yml +++ b/muscle-mis/src/main/resources/application-test.yml @@ -1,8 +1,4 @@ spring: - cloud: - consul: - host: maf.consul-service-registry.test - port: 8500 zipkin: base-url: http://maf.zipkin.test:9411 devtools: diff --git a/muscle-mis/src/main/resources/application.yml b/muscle-mis/src/main/resources/application.yml index 43dc1da4..24ea49d6 100644 --- a/muscle-mis/src/main/resources/application.yml +++ b/muscle-mis/src/main/resources/application.yml @@ -18,21 +18,10 @@ spring: probability: 1.0 cloud: consul: - config: - enabled: true - prefix: config - # `default-context` should be equal to Spring application name - default-context: ${spring.application.name} - profile-separator: "-" - format: YAML - data-key: "data" - watch: - enabled: true - delay: 1000 discovery: register: true - instance-id: ${spring.cloud.client.hostname}-${spring.cloud.client.ip-address}-${server.port}-${spring.application.name} - service-name: ${spring.application.name} + instance-id: ${spring.cloud.client.hostname}-${spring.cloud.client.ip-address}-${server.port}-@project.artifactId@ + service-name: @project.artifactId@ port: ${server.port} prefer-ip-address: true ip-address: ${spring.cloud.client.ip-address} @@ -172,7 +161,7 @@ maf: - "/*/v2/api-docs/**" - "/webjars/**" - "/doc.html" - included-package-for-http-api-scan: ${project.property.base-package} + included-package-for-http-api-scan: ${maf.project-property.base-package} sftp: client: diff --git a/muscle-mis/src/main/resources/bootstrap.yml b/muscle-mis/src/main/resources/bootstrap.yml new file mode 100644 index 00000000..b62087da --- /dev/null +++ b/muscle-mis/src/main/resources/bootstrap.yml @@ -0,0 +1,18 @@ +spring: + application: + name: @project.artifactId@ + cloud: + consul: + host: "should-be-passed-by-java-opts" + port: 8500 + config: + enabled: true + prefix: config + # `default-context` should be equal to Spring application name + default-context: @project.artifactId@ + profile-separator: '::' + format: YAML + data-key: "data" + watch: + enabled: true + delay: 1000 diff --git a/pom.xml b/pom.xml index 27a6f67b..bf3dc1cb 100644 --- a/pom.xml +++ b/pom.xml @@ -162,6 +162,42 @@ ${project.artifactId}-${project.version} + + + ${basedir}/src/main/resources + true + + **/application*.yml + **/application*.yaml + **/application*.properties + + + + ${basedir}/src/main/resources + + **/application*.yml + **/application*.yaml + **/application*.properties + + + + true + ${basedir}/src/main/resources + + **/bootstrap*.yml + **/bootstrap*.yaml + **/bootstrap*.properties + + + + ${basedir}/src/main/resources + + **/bootstrap*.yml + **/bootstrap*.yaml + **/bootstrap*.properties + + + diff --git a/reactive-spring-boot-starter/pom.xml b/reactive-spring-boot-starter/pom.xml index 3f8cfc42..d85091b6 100644 --- a/reactive-spring-boot-starter/pom.xml +++ b/reactive-spring-boot-starter/pom.xml @@ -54,11 +54,11 @@ org.springframework.cloud - spring-cloud-starter-consul-discovery + spring-cloud-starter-bootstrap org.springframework.cloud - spring-cloud-starter-consul-config + spring-cloud-starter-consul-all org.springframework.cloud diff --git a/spring-boot-admin/src/main/resources/application-development-docker.yml b/spring-boot-admin/src/main/resources/application-development-docker.yml index b4aae1a2..fd36a358 100644 --- a/spring-boot-admin/src/main/resources/application-development-docker.yml +++ b/spring-boot-admin/src/main/resources/application-development-docker.yml @@ -1,10 +1,6 @@ spring: devtools: add-properties: true - cloud: - consul: - host: maf.consul-service-registry.development - port: 8500 zipkin: base-url: http://maf.zipkin.development:9411 datasource: diff --git a/spring-boot-admin/src/main/resources/application-development-local.yml b/spring-boot-admin/src/main/resources/application-development-local.yml index 5b4afd93..0c1a0b81 100644 --- a/spring-boot-admin/src/main/resources/application-development-local.yml +++ b/spring-boot-admin/src/main/resources/application-development-local.yml @@ -1,10 +1,6 @@ spring: devtools: add-properties: true - cloud: - consul: - host: localhost - port: 8500 zipkin: base-url: http://localhost:9411 datasource: diff --git a/spring-boot-admin/src/main/resources/application-production.yml b/spring-boot-admin/src/main/resources/application-production.yml index 6dcd9ee7..b809de60 100644 --- a/spring-boot-admin/src/main/resources/application-production.yml +++ b/spring-boot-admin/src/main/resources/application-production.yml @@ -1,10 +1,6 @@ spring: devtools: add-properties: false - cloud: - consul: - host: maf.consul-service-registry.production - port: 8500 zipkin: base-url: http://maf.zipkin.production:9411 datasource: diff --git a/spring-boot-admin/src/main/resources/application-stage.yml b/spring-boot-admin/src/main/resources/application-stage.yml index 6ad0578d..48edd4d7 100644 --- a/spring-boot-admin/src/main/resources/application-stage.yml +++ b/spring-boot-admin/src/main/resources/application-stage.yml @@ -1,10 +1,6 @@ spring: devtools: add-properties: false - cloud: - consul: - host: maf.consul-service-registry.stage - port: 8500 zipkin: base-url: http://maf.zipkin.stage:9411 datasource: diff --git a/spring-boot-admin/src/main/resources/application-test.yml b/spring-boot-admin/src/main/resources/application-test.yml index bd9cce19..41fa5689 100644 --- a/spring-boot-admin/src/main/resources/application-test.yml +++ b/spring-boot-admin/src/main/resources/application-test.yml @@ -1,10 +1,6 @@ spring: devtools: add-properties: false - cloud: - consul: - host: maf.consul-service-registry.test - port: 8500 zipkin: base-url: http://maf.zipkin.test:9411 datasource: diff --git a/spring-boot-admin/src/main/resources/application.yml b/spring-boot-admin/src/main/resources/application.yml index 4c5980c9..bcedbcb8 100644 --- a/spring-boot-admin/src/main/resources/application.yml +++ b/spring-boot-admin/src/main/resources/application.yml @@ -15,21 +15,10 @@ spring: time-zone: Asia/Hong_Kong cloud: consul: - config: - enabled: true - prefix: config - # `default-context` should be equal to Spring application name - default-context: ${spring.application.name} - profile-separator: "-" - format: YAML - data-key: "data" - watch: - enabled: true - delay: 1000 discovery: register: true - instance-id: ${spring.cloud.client.hostname}-${spring.cloud.client.ip-address}-${server.port}-${spring.application.name} - service-name: ${spring.application.name} + instance-id: ${spring.cloud.client.hostname}-${spring.cloud.client.ip-address}-${server.port}-@project.artifactId@ + service-name: @project.artifactId@ port: ${server.port} prefer-ip-address: true ip-address: ${spring.cloud.client.ip-address} @@ -131,7 +120,7 @@ maf: - "/*/v2/api-docs/**" - "/webjars/**" - "/doc.html" - included-package-for-http-api-scan: ${project.property.base-package} + included-package-for-http-api-scan: ${maf.project-property.base-package} sftp: client: diff --git a/spring-boot-admin/src/main/resources/bootstrap.yml b/spring-boot-admin/src/main/resources/bootstrap.yml new file mode 100644 index 00000000..b62087da --- /dev/null +++ b/spring-boot-admin/src/main/resources/bootstrap.yml @@ -0,0 +1,18 @@ +spring: + application: + name: @project.artifactId@ + cloud: + consul: + host: "should-be-passed-by-java-opts" + port: 8500 + config: + enabled: true + prefix: config + # `default-context` should be equal to Spring application name + default-context: @project.artifactId@ + profile-separator: '::' + format: YAML + data-key: "data" + watch: + enabled: true + delay: 1000 diff --git a/spring-boot-starter/pom.xml b/spring-boot-starter/pom.xml index 0e83d63e..39f1fea1 100644 --- a/spring-boot-starter/pom.xml +++ b/spring-boot-starter/pom.xml @@ -54,11 +54,11 @@ org.springframework.cloud - spring-cloud-starter-consul-discovery + spring-cloud-starter-bootstrap org.springframework.cloud - spring-cloud-starter-consul-config + spring-cloud-starter-consul-all org.springframework.cloud diff --git a/spring-boot-starter/src/main/java/com/jmsoftware/maf/springbootstarter/MafAutoConfiguration.java b/spring-boot-starter/src/main/java/com/jmsoftware/maf/springbootstarter/MafAutoConfiguration.java index ca30453a..3e4683b1 100644 --- a/spring-boot-starter/src/main/java/com/jmsoftware/maf/springbootstarter/MafAutoConfiguration.java +++ b/spring-boot-starter/src/main/java/com/jmsoftware/maf/springbootstarter/MafAutoConfiguration.java @@ -27,6 +27,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.web.servlet.error.ErrorAttributes; import org.springframework.boot.web.servlet.error.ErrorController; +import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; @@ -46,7 +47,7 @@ @Configuration @IntegrationComponentScan @ConditionalOnWebApplication -@AutoConfigureOrder(Integer.MIN_VALUE) +//@AutoConfigureOrder(Integer.MIN_VALUE) @EnableConfigurationProperties(MafConfiguration.class) @Import({ MyBatisPlusConfiguration.class, @@ -145,6 +146,7 @@ public HttpApiResourceRemoteApiController httpApiResourceRemoteController(MafCon } @Bean + @RefreshScope public CommonService commonService(MafProjectProperty mafProjectProperty) { log.warn("Initial bean: '{}'", CommonServiceImpl.class.getSimpleName()); return new CommonServiceImpl(mafProjectProperty); diff --git a/spring-boot-starter/src/main/java/com/jmsoftware/maf/springbootstarter/service/impl/CommonServiceImpl.java b/spring-boot-starter/src/main/java/com/jmsoftware/maf/springbootstarter/service/impl/CommonServiceImpl.java index 4b05c0d6..cc7dc4ba 100644 --- a/spring-boot-starter/src/main/java/com/jmsoftware/maf/springbootstarter/service/impl/CommonServiceImpl.java +++ b/spring-boot-starter/src/main/java/com/jmsoftware/maf/springbootstarter/service/impl/CommonServiceImpl.java @@ -7,6 +7,7 @@ import com.jmsoftware.maf.springbootstarter.service.CommonService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import javax.validation.Valid; @@ -24,9 +25,12 @@ public class CommonServiceImpl implements CommonService { private final MafProjectProperty mafProjectProperty; + @Value("${greeting: Hello, World! (Embedded in Java)}") + private String greeting; + @Override public JSON getApplicationInfo() { - return JSONUtil.parse(mafProjectProperty); + return JSONUtil.parseObj(mafProjectProperty).set("greeting", greeting); } @Override