My config client fetch config client but does not see config server config file

34 Views Asked by At

Hey guys I need your help here. I am new to Spring config server and I have an issue here. I've created a config server app and a config client service named account-service. I've created the bootstap.yml file in config-server/resources path. Also created a new directory in resources directory and there is file in it named account-service.yml. I've put the configuration about account service there. Also I've created bootstrap.yml file in the account-service project in resources directory. The thing is when I search http://localhost:8888/account-service.yml it gets the expected json (account-service properties). But when I run the account-service app it fetches config server but find nothing. So, I cannot load database connection properties. So, the application does not run. I will put my configuration files and pom.xml dependencies so that you can imagine the situation better. Can you help on these. I'am stuck and I need your help.

config-server: resources/bootstap.yml:

server:
  port: 8888
spring:
  cloud:
    config:
      server:
        native:
          search-locations: classpath:/config
  profiles:
    active: native

config-server: /resources/account-service.yml:

server:
  port: 8081
microservice:
  cassandra:
    contact:
      point: 127.0.0.1
    keyspace:
      name: springcloud
    port: 9042
    username: cassandra
    password: cassandra

account-service: /resources/bootstrap.yml:

spring:
  application:
    name: account-service # Search for account-service.yml in the config server
  cloud:
    config:
      profile: native
      uri: http://localhost:8888 # Config server URL

account-service parent dependencies:

<dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-config</artifactId>
    </dependency>
    <spring.cloud.version>2023.0.0</spring.cloud.version>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring.cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

config-server dependencies:

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
     <groupId>org.springframework.cloud</groupId>
     <artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>

Account service log:

2024-02-05T20:04:01.952+03:00  INFO 5086 --- [  restartedMain] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8888
2024-02-05T20:04:02.060+03:00  INFO 5086 --- [  restartedMain] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=application, profiles=[default], label=null, version=null, state=null
2024-02-05T20:04:02.060+03:00  INFO 5086 --- [  restartedMain] b.c.PropertySourceBootstrapConfiguration : Located property source: [BootstrapPropertySource {name='bootstrapProperties-configClient'}]
2024-02-05T20:04:02.063+03:00  INFO 5086 --- [  restartedMain] c.a.a.AccountServiceApplication          : No active profile set, falling back to 1 default profile: "default"
2024-02-05T20:04:02.255+03:00  INFO 5086 --- [  restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Cassandra repositories in DEFAULT mode.
2024-02-05T20:04:02.260+03:00  INFO 5086 --- [  restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 2 ms. Found 0 Cassandra repository interfaces.
2024-02-05T20:04:02.371+03:00  INFO 5086 --- [  restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Reactive Cassandra repositories in DEFAULT mode.
2024-02-05T20:04:02.378+03:00  INFO 5086 --- [  restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 6 ms. Found 0 Reactive Cassandra repository interfaces.
2024-02-05T20:04:02.379+03:00  INFO 5086 --- [  restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Cassandra repositories in DEFAULT mode.
2024-02-05T20:04:02.385+03:00  INFO 5086 --- [  restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 5 ms. Found 1 Cassandra repository interface.
2024-02-05T20:04:02.452+03:00  INFO 5086 --- [  restartedMain] o.s.cloud.context.scope.GenericScope     : BeanFactory id=e6a017c7-8b55-3032-b079-c077a9801003
2024-02-05T20:04:02.619+03:00  INFO 5086 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port 8080 (http)
2024-02-05T20:04:02.623+03:00  INFO 5086 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2024-02-05T20:04:02.623+03:00  INFO 5086 --- [  restartedMain] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.18]
2024-02-05T20:04:02.642+03:00  INFO 5086 --- [  restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2024-02-05T20:04:02.642+03:00  INFO 5086 --- [  restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 574 ms
2024-02-05T20:04:02.704+03:00  WARN 5086 --- [  restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'accountController' defined in file [/Users/ademgalitekin/Desktop/Software/Self Projects/microservice/parent/account-service/target/classes/com/adamsware/accountservice/api/AccountController.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'accountService' defined in file [/Users/ademgalitekin/Desktop/Software/Self Projects/microservice/parent/account-service/target/classes/com/adamsware/accountservice/service/AccountService.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'accountRepository' defined in com.adamsware.accountservice.repository.AccountRepository defined in @EnableCassandraRepositories declared on CassandraRepositoriesRegistrar.EnableCassandraRepositoriesConfiguration: Cannot resolve reference to bean 'cassandraTemplate' while setting bean property 'cassandraTemplate'
2024-02-05T20:04:02.705+03:00  INFO 5086 --- [  restartedMain] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2024-02-05T20:04:02.715+03:00  INFO 5086 --- [  restartedMain] .s.b.a.l.ConditionEvaluationReportLogger : 

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2024-02-05T20:04:02.724+03:00 ERROR 5086 --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'accountController' defined in file [/Users/ademgalitekin/Desktop/Software/Self Projects/microservice/parent/account-service/target/classes/com/adamsware/accountservice/api/AccountController.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'accountService' defined in file [/Users/ademgalitekin/Desktop/Software/Self Projects/microservice/parent/account-service/target/classes/com/adamsware/accountservice/service/AccountService.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'accountRepository' defined in com.adamsware.accountservice.repository.AccountRepository defined in @EnableCassandraRepositories declared on CassandraRepositoriesRegistrar.EnableCassandraRepositoriesConfiguration: Cannot resolve reference to bean 'cassandraTemplate' while setting bean property 'cassandraTemplate'
0

There are 0 best solutions below