Search code examples
spring-bootgithubspring-cloud-config-serverjava-21

Spring Boot Config Server returns empty for property Sources


I am trying to set up Spring-boot Cloud Config Server

But the response I keep getting is null on the propertySources. I have used {application-name}-{profile}.properties format

{"name":"spring-config-server","profiles":["local"],"label":null,"version":"e803f9aafafb279653645dfedcdc26eb8f036e3c","state":null,"propertySources":[]}

File : server-configs/spring-config-server-local.properties

server.url = localhost:8080/local
random.property = completely_random

The application.properties file is:

spring.application.name=spring-config-server
spring.profile.active: local
spring.cloud.config.server.git.uri = https://github.com/VigneshV72/Spring-Config-Server
spring.cloud.config.server.git.search-paths= = server-configs/
server.port = 8090
logging.level.web=DEBUG
management.security.enabled:false

The pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.1.5</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.vv.spring</groupId>
    <artifactId>spring-config-server</artifactId>
    <version>1.0.0</version>
    <name>spring-Config-Server</name>
    <description></description>
    <properties>
        <java.version>21</java.version>
        <spring-cloud.version>2022.0.4</spring-cloud.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-config-server</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <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>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

The debug logs are

2023-11-23T20:05:33.063+05:30  INFO 20580 --- [nio-8090-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2023-11-23T20:05:33.063+05:30  INFO 20580 --- [nio-8090-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2023-11-23T20:05:33.063+05:30 DEBUG 20580 --- [nio-8090-exec-1] o.s.web.servlet.DispatcherServlet        : Detected StandardServletMultipartResolver
2023-11-23T20:05:33.063+05:30 DEBUG 20580 --- [nio-8090-exec-1] o.s.web.servlet.DispatcherServlet        : Detected AcceptHeaderLocaleResolver
2023-11-23T20:05:33.063+05:30 DEBUG 20580 --- [nio-8090-exec-1] o.s.web.servlet.DispatcherServlet        : Detected FixedThemeResolver
2023-11-23T20:05:33.064+05:30 DEBUG 20580 --- [nio-8090-exec-1] o.s.web.servlet.DispatcherServlet        : Detected org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator@7130885b
2023-11-23T20:05:33.064+05:30 DEBUG 20580 --- [nio-8090-exec-1] o.s.web.servlet.DispatcherServlet        : Detected org.springframework.web.servlet.support.SessionFlashMapManager@5249520e
2023-11-23T20:05:33.064+05:30 DEBUG 20580 --- [nio-8090-exec-1] o.s.web.servlet.DispatcherServlet        : enableLoggingRequestDetails='false': request parameters and headers will be masked to prevent unsafe logging of potentially sensitive data
2023-11-23T20:05:33.064+05:30  INFO 20580 --- [nio-8090-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 1 ms
2023-11-23T20:05:33.085+05:30 DEBUG 20580 --- [nio-8090-exec-1] o.s.web.servlet.DispatcherServlet        : GET "/spring-config-server/local", parameters={}
2023-11-23T20:05:33.093+05:30 DEBUG 20580 --- [nio-8090-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to org.springframework.cloud.config.server.environment.EnvironmentController#defaultLabel(String, String)
2023-11-23T20:05:42.954+05:30 DEBUG 20580 --- [nio-8090-exec-1] m.m.a.RequestResponseBodyMethodProcessor : Using 'application/json;q=0.8', given [text/html, application/xhtml+xml, image/avif, image/webp, image/apng, application/xml;q=0.9, */*;q=0.8, application/signed-exchange;v=b3;q=0.7] and supported [application/json]
2023-11-23T20:05:42.986+05:30 DEBUG 20580 --- [nio-8090-exec-1] m.m.a.RequestResponseBodyMethodProcessor : Writing [Environment [name=spring-config-server, profiles=[local], label=null, propertySources=[], version=e8 (truncated)...]
2023-11-23T20:05:43.004+05:30 DEBUG 20580 --- [nio-8090-exec-1] o.s.web.servlet.DispatcherServlet        : Completed 200 OK
2023-11-23T20:08:31.126+05:30 DEBUG 20580 --- [nio-8090-exec-3] o.s.web.servlet.DispatcherServlet        : GET "/local", parameters={}
2023-11-23T20:08:31.131+05:30 DEBUG 20580 --- [nio-8090-exec-3] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped to ResourceHttpRequestHandler [classpath [META-INF/resources/], classpath [resources/], classpath [static/], classpath [public/], ServletContext [/]]
2023-11-23T20:08:31.135+05:30 DEBUG 20580 --- [nio-8090-exec-3] o.s.w.s.r.ResourceHttpRequestHandler     : Resource not found
2023-11-23T20:08:31.135+05:30 DEBUG 20580 --- [nio-8090-exec-3] o.s.web.servlet.DispatcherServlet        : Completed 404 NOT_FOUND
2023-11-23T20:08:31.139+05:30 DEBUG 20580 --- [nio-8090-exec-3] o.s.web.servlet.DispatcherServlet        : "ERROR" dispatch for GET "/error", parameters={}
2023-11-23T20:08:31.140+05:30 DEBUG 20580 --- [nio-8090-exec-3] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController#errorHtml(HttpServletRequest, HttpServletResponse)
2023-11-23T20:08:31.174+05:30 DEBUG 20580 --- [nio-8090-exec-3] o.s.w.s.v.ContentNegotiatingViewResolver : Selected 'text/html' given [text/html, text/html;q=0.8]
2023-11-23T20:08:31.178+05:30 DEBUG 20580 --- [nio-8090-exec-3] o.s.web.servlet.DispatcherServlet        : Exiting from "ERROR" dispatch, status 404

Can anyone help me figure out why I am not getting any of the configs in http://localhost:8090/spring-config-server/local?

I have tried changing names. I have tried linking it to other public repos to get the properties from there. I have tried directly hitting the local profile in the url. http://localhost:8090/local. But nothing has worked so far

I would like to understand what I have done wrong

UPDATES

I realized I was using spring.profile.active : local instead of spring.profiles.active = local, so I made that correction. But it still fails.

I tried uploading to password restricted git and added these properties as well

spring.cloud.config.server.git.username=username
spring.cloud.config.server.git.password=password

Solution

  • After a lot of trial and errors I finally realized that I messed up the application properties. In addition the mistake on profiles I have mentioned in update I also found the I used two "=" in search-paths. Once I fixed and updated the application properties file, it started working properly.

    spring.application.name=spring-config-server
    spring.profile.active= local
    spring.cloud.config.server.git.uri = https://github.com/VigneshV72/Spring-Config-Server
    spring.cloud.config.server.git.search-paths= server-configs/
    server.port = 8090
    logging.level.web=DEBUG
    management.security.enabled:false