Skip to content

Commit

Permalink
fix nacos cluster_name contains _ error
Browse files Browse the repository at this point in the history
  • Loading branch information
zhoutaoo committed Feb 3, 2024
1 parent 864623b commit 84e96bd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
package io.github.opensabre.boot.config;

import lombok.NonNull;
import org.springframework.boot.env.YamlPropertySourceLoader;
import org.springframework.core.env.PropertySource;
import org.springframework.core.io.support.DefaultPropertySourceFactory;
import org.springframework.core.io.support.EncodedResource;

import java.io.IOException;
import java.util.Objects;

/**
* 加载yaml的Factory
*/
public class YamlPropertyLoaderFactory extends DefaultPropertySourceFactory {

@Override
public PropertySource<?> createPropertySource(String name, EncodedResource resource) throws IOException {
if (Objects.isNull(resource)) {
super.createPropertySource(name, resource);
}
public @NonNull PropertySource<?> createPropertySource(String name, EncodedResource resource) throws IOException {
return new YamlPropertySourceLoader().load(resource.getResource().getFilename(), resource.getResource()).get(0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ spring:
watch:
enabled: true
enabled: true
cluster-name: CLUSTER_${CLOUD_AZ:LOCAL} # 取环境变量AZ做为部分集群名:CLUSTER_SH,无环境变量默认为CLUSTER_LOCAL代表本地开发实例
cluster-name: CLUSTER-${CLOUD_AZ:LOCAL} # 取环境变量AZ做为部分集群名:CLUSTER-SH,无环境变量默认为CLUSTER-LOCAL代表本地开发实例

0 comments on commit 84e96bd

Please sign in to comment.