Клиент конфигурации не может получить измененные значения свойств из измененных файлов свойств в Git.Мне нужна помощь в решении этой проблемы.
Я создал новый конфигурационный сервер и клиент Spring.Первоначально значения из файлов свойств были выбраны правильно.Когда я изменил значения в файле свойств, клиент все еще возвращал старые значения.Я попытался POSTing к http://localhost:8080/actuator/refresh, и даже после этого старые значения возвращаются.Наконец, я удалил файл свойств из репозитория git, и клиент все еще возвращает старые значения.
Config Server bootstrap.properties
spring.application.name=ConfigServer
server.port=8888
encrypt.key=123456
spring.security.user.password=configpassword123
spring.cloud.config.server.git.uri=https://some-repository/ConfigRepo.git
spring.cloud.config.server.git.username=git_user
spring.cloud.config.server.git.password=git_password
ConfigServer.java
@Configuration
@EnableDiscoveryClient
@SpringBootApplication
@EnableConfigServer
public class ConfigServer {
public static void main(String[] args) {
SpringApplication.run(ConfigServer.class, args);
}
}
WebSecurityConfiguration.java
@Configuration
@EnableWebSecurity
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable().authorizeRequests()
.anyRequest().authenticated().and().httpBasic();
}
}
Config Client bootstrap.properties
spring.application.name=config-client
spring.cloud.config.uri=http://config-server:8888
spring.cloud.config.username=user
spring.cloud.config.password=configpassword123
management.endpoints.web.exposure.include=*
Config Client Controller Class
@RefreshScope
@RestController
public class ConfigController {
@Value("${applicationname}")
private String appName;
@Value("${username}")
private String username;
@Value("${password}")
private String password;
@Value("${instancename}")
private String environment;
@Value("${dbconnection}")
private String dbConnection;
@GetMapping("/user")
public String getUser() {
return "Application: "+ appName +" Instance: "+ environment + " User: " + username + " / " + password;
}
@GetMapping("/dbconn")
public String getDBConnection() {
return dbConnection;
}
}