Skip to content

Spring-consul for centralized configuration #1

Open
@andreykirson

Description

@andreykirson

Hi, I'm a little bit confused about how to use spring-consul.
I can set default value but if it needs a more specified value in another folder for example config/multiplication/production
spring does not use it and still uses the default value.

Here are my start app logs.

C:\Users\79143\Documents\Pet Project\mental_arithmetic>mvn spring-boot:run -Dspring-boot.run.arguments="--spring.profiles.active=default,multiplication"
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------< com.example:mental_arithmetic >--------------------
[INFO] Building mental_arithmetic 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] >>> spring-boot-maven-plugin:2.5.2:run (default-cli) > test-compile @ mental_arithmetic >>>
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ mental_arithmetic ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 1 resource
[INFO] Copying 26 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ mental_arithmetic ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) @ mental_arithmetic ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] skip non existing resourceDirectory C:\Users\79143\Documents\Pet Project\mental_arithmetic\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ mental_arithmetic ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] <<< spring-boot-maven-plugin:2.5.2:run (default-cli) < test-compile @ mental_arithmetic <<<
[INFO]
[INFO]
[INFO] --- spring-boot-maven-plugin:2.5.2:run (default-cli) @ mental_arithmetic ---
[INFO] Attaching agents: []
2021-08-19 09:48:54.617  INFO 25252 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.retry.annotation.RetryConfiguration' of type [org.springframework.retry.annotation.RetryConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.5.2)

2021-08-19 09:48:55.293  INFO 25252 --- [           main] b.c.PropertySourceBootstrapConfiguration : Located property source: [BootstrapPropertySource {name='bootstrapProperties-config/application,multiplication/'}, BootstrapPropertySource {name='bootstrapProperties-config/application,default/'}, BootstrapPropertySource {name='bootstrapProperties-config/application/'}, BootstrapPropertySource {name='bootstrapProperties-config/default,multiplication/'}, BootstrapPropertySource {name='bootstrapProperties-config/default,default/'}, BootstrapPropertySource {name='bootstrapProperties-config/default/'}]
2021-08-19 09:48:55.302  INFO 25252 --- [           main] c.e.m.MentalArithmeticApplication        : The following profiles are active: default,multiplication
2021-08-19 09:48:55.897  INFO 25252 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-08-19 09:48:56.019  INFO 25252 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 115 ms. Found 2 JPA repository interfaces.
2021-08-19 09:48:56.172  INFO 25252 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=135ad83f-97aa-3adf-843b-6bc922475774
2021-08-19 09:48:56.240  INFO 25252 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.retry.annotation.RetryConfiguration' of type [org.springframework.retry.annotation.RetryConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-08-19 09:48:56.449  INFO 25252 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8081 (http)
2021-08-19 09:48:56.458  INFO 25252 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2021-08-19 09:48:56.459  INFO 25252 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.48]
2021-08-19 09:48:56.591  INFO 25252 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2021-08-19 09:48:56.591  INFO 25252 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1277 ms
2021-08-19 09:48:56.687  INFO 25252 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2021-08-19 09:48:56.911  INFO 25252 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2021-08-19 09:48:56.916  INFO 25252 --- [           main] o.s.b.a.h2.H2ConsoleAutoConfiguration    : H2 console available at '/h2-console'. Database available at 'jdbc:h2:file:~/mental_arithmetic'
2021-08-19 09:48:57.029  INFO 25252 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-08-19 09:48:57.068  INFO 25252 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.4.32.Final
2021-08-19 09:48:57.168  INFO 25252 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2021-08-19 09:48:57.274  INFO 25252 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2021-08-19 09:48:57.773  INFO 25252 --- [           main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-08-19 09:48:57.781  INFO 25252 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2021-08-19 09:48:58.188  WARN 25252 --- [           main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2021-08-19 09:48:58.340  INFO 25252 --- [           main] o.s.b.a.w.s.WelcomePageHandlerMapping    : Adding welcome page: class path resource [static/index.html]
2021-08-19 09:48:58.808  WARN 25252 --- [           main] iguration$LoadBalancerCaffeineWarnLogger : Spring Cloud LoadBalancer is currently working with the default cache. You can switch to using Caffeine cache, by adding it and org.springframework.cache.caffeine.CaffeineCacheManager to the classpath.
2021-08-19 09:48:58.814  INFO 25252 --- [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 1 endpoint(s) beneath base path '/actuator'
2021-08-19 09:48:58.882  INFO 25252 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8081 (http) with context path ''
2021-08-19 09:48:58.890  INFO 25252 --- [           main] o.s.c.c.s.ConsulServiceRegistry          : Registering service with consul: NewService{id='multiplication-8081', name='multiplication', tags=[], address='LAPTOP-BIO148TB', meta={secure=false}, port=8081, enableTagOverride=null, check=Check{script='null', dockerContainerID='null', shell='null', interval='10s', ttl='null', http='http://LAPTOP-BIO148TB:8081/actuator/health', method='null', header={}, tcp='null', timeout='null', deregisterCriticalServiceAfter='null', tlsSkipVerify=null, status='null', grpc='null', grpcUseTLS=null}, checks=null}
2021-08-19 09:48:58.996  INFO 25252 --- [           main] c.e.m.MentalArithmeticApplication        : Started MentalArithmeticApplication in 5.1 seconds (JVM running for 5.465)
2021-08-19 09:49:08.602  INFO 25252 --- [nio-8081-exec-2] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2021-08-19 09:49:08.602  INFO 25252 --- [nio-8081-exec-2] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2021-08-19 09:49:08.606  INFO 25252 --- [nio-8081-exec-2] o.s.web.servlet.DispatcherServlet        : Completed initialization in 2 ms
2021-08-19 09:49:08.635  INFO 25252 --- [nio-8081-exec-2] o.s.a.r.c.CachingConnectionFactory       : Attempting to connect to: [localhost:5672]
2021-08-19 09:49:08.674  INFO 25252 --- [nio-8081-exec-2] o.s.a.r.c.CachingConnectionFactory       : Created new connection: rabbitConnectionFactory#52a23575:0/SimpleConnection@1a951593 [delegate=amqp://guest@127.0.0.1:5672/, localPort= 59802]
2021-08-19 09:49:08.675 DEBUG 25252 --- [nio-8081-exec-2] o.s.amqp.rabbit.core.RabbitAdmin         : Initializing declarations
2021-08-19 09:49:08.692 DEBUG 25252 --- [nio-8081-exec-2] o.s.amqp.rabbit.core.RabbitAdmin         : declaring Exchange 'attempts.topic'
2021-08-19 09:49:08.696 DEBUG 25252 --- [nio-8081-exec-2] o.s.amqp.rabbit.core.RabbitAdmin         : Declarations finished

This is my current state of the app https://github.com/andreykirson/mental_arithmetic/tree/getway

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions