I have configured a Spring Cloud Config Server that's pulling the application values from our git repository. I can confirm that it's getting the values correctly by browsing the spring cloud url [http://localhost:8012/XXXAPIConfigServer/default]
Now in my client microservice (users-ws) I've added the following dependency and configurations
bootstrap.yml
spring:
cloud:
config:
uri: http://localhost:8012
name: XXXAPIConfigServer
profiles:
active: default
application.yml
jwt:
secretKey: v++?c2HNyw^Eq#Ba=nFTYNRuSF1bKx
prefix: Bearer
expirationAfterDays: 1
When I run the client user service I'm not getting the expirationAfterDays
value 2
but 1
.
Additionally, I am reading those jwt values by calling a jwtclass JwtConfig
package com.company.abc.api.users.configuration;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpHeaders;
@Configuration
@ConfigurationProperties(prefix = "jwt")
public class JwtConfig {
private String secretKey;
private String prefix;
private int expirationAfterDays;
private String loginUrl;
public JwtConfig() {}
public String getSecretKey() {
return secretKey;
}
public void setSecretKey(String secretKey) {
this.secretKey = secretKey;
}
public String getPrefix() {
return prefix;
}
public void setPrefix(String prefix) {
this.prefix = prefix;
}
public int getExpirationAfterDays() {
return expirationAfterDays;
}
public void setExpirationAfterDays(int expirationAfterDays) {
this.expirationAfterDays = expirationAfterDays;
}
public String getLoginUrl() {
return loginUrl;
}
public void setLoginUrl(String loginUrl) {
this.loginUrl = loginUrl;
}
public String getAuthorizationHeader() {
return HttpHeaders.AUTHORIZATION;
}
}
Here is the log file from the client api user service: (https://justpaste.it/8aeop)
I found out what's causing the problem. I have the same bootstrap.yml config with Zuul API Gateway and I noticed that I'm using the following versions:
spring-boot-starter-parent => 2.3.6.RELEASE
sprint-cloud.version => Hoxton.SR9
Where as in User Web Service I'm using (not working)
spring-boot-starter-parent => 2.4.0
sprint-cloud.version => 2020.0.0-SNAPSHOT