Remove @Value annotation from classed annotated with @ConfigurationProperties annotation

pull/425/head
DerekYRC 3 years ago
parent 793c3acada
commit 5e9f3337de

@ -149,10 +149,10 @@
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
</plugin>
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-checkstyle-plugin</artifactId>-->
<!-- </plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
@ -222,10 +222,10 @@
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
</plugin>
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-checkstyle-plugin</artifactId>-->
<!-- </plugin>-->
</plugins>
</reporting>

@ -48,7 +48,8 @@ public class PolarisDiscoveryProperties {
@PostConstruct
public void init() {
if (StringUtils.isEmpty(service)) {
service = environment.getProperty("spring.cloud.polaris.service"); if (StringUtils.isEmpty(service)) {
service = environment.getProperty("spring.cloud.polaris.service");
if (StringUtils.isEmpty(service)) {
service = environment.getProperty("spring.application.name");
}
}
@ -226,7 +227,20 @@ public class PolarisDiscoveryProperties {
@Override
public String toString() {
return "PolarisDiscoveryProperties{" + "namespace='" + namespace + '\'' + ", service='" + service + '\'' + ", token='" + token + '\'' + ", weight=" + weight + ", version='" + version + '\'' + ", protocol='" + protocol + '\'' + ", port=" + port + ", enabled=" + enabled + ", registerEnabled=" + registerEnabled + ", heartbeatEnabled=" + heartbeatEnabled + ", healthCheckUrl='" + healthCheckUrl + '\'' + ", serviceListRefreshInterval=" + serviceListRefreshInterval + '}';
return "PolarisDiscoveryProperties{" +
"namespace='" + namespace + '\'' +
", service='" + service + '\'' +
", token='" + token + '\'' +
", weight=" + weight +
", version='" + version + '\'' +
", protocol='" + protocol + '\'' +
", port=" + port +
", enabled=" + enabled +
", registerEnabled=" + registerEnabled +
", heartbeatEnabled=" + heartbeatEnabled +
", healthCheckUrl='" + healthCheckUrl + '\'' +
", serviceListRefreshInterval=" + serviceListRefreshInterval +
'}';
}
@Bean
@ -246,10 +260,12 @@ public class PolarisDiscoveryProperties {
public void modify(ConfigurationImpl configuration) {
if (polarisDiscoveryProperties != null) {
DiscoveryConfigImpl discoveryConfig = new DiscoveryConfigImpl();
discoveryConfig.setServerConnectorId(ID); discoveryConfig.setEnable(polarisDiscoveryProperties.enabled);
discoveryConfig.setServerConnectorId(ID);
discoveryConfig.setEnable(polarisDiscoveryProperties.enabled);
configuration.getConsumer().getDiscoveries().add(discoveryConfig);
RegisterConfigImpl registerConfig = new RegisterConfigImpl(); registerConfig.setServerConnectorId(ID);
RegisterConfigImpl registerConfig = new RegisterConfigImpl();
registerConfig.setServerConnectorId(ID);
registerConfig.setEnable(polarisDiscoveryProperties.registerEnabled);
configuration.getProvider().getRegisters().add(registerConfig);
}

Loading…
Cancel
Save