1
0
mirror of https://gitee.com/mirrors/Spring-Cloud-Alibaba.git synced 2021-06-26 13:25:11 +08:00

add additional spring configuration metadata

This commit is contained in:
flystar32 2018-09-17 14:39:34 +08:00
parent 2466cbddb8
commit 1dfcd8796b
6 changed files with 63 additions and 58 deletions

View File

@ -45,7 +45,12 @@
<scope>provided</scope> <scope>provided</scope>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId> <artifactId>spring-boot</artifactId>

View File

@ -35,12 +35,12 @@ public class NacosConfigProperties {
private String serverAddr; private String serverAddr;
/** /**
* nacos config encode * encode for nacos config content.
*/ */
private String encode; private String encode;
/** /**
* nacos config group * nacos config group, group is config data meta info.
*/ */
private String group = "DEFAULT_GROUP"; private String group = "DEFAULT_GROUP";
@ -49,37 +49,37 @@ public class NacosConfigProperties {
*/ */
private String prefix; private String prefix;
/** /**
* nacos config dataId contentType * the content type of nacos config content.
*/ */
private String contentType = "properties"; private String contentType = "properties";
/** /**
* timeout to get configuration * timeout for get config from nacos.
*/ */
private int timeout = 3000; private int timeout = 3000;
/** /**
* endpoint for Nacos * endpoint for Nacos, the domain name of a service, through which the server address can be dynamically obtained.
*/ */
private String endpoint; private String endpoint;
/** /**
* Nacos namespace * namespace, separation configuration of different environments.
*/ */
private String namespace; private String namespace;
/** /**
* Nacos access key * access key for namespace.
*/ */
private String accessKey; private String accessKey;
/** /**
* Nacos secret key * secret key for namespace.
*/ */
private String secretKey; private String secretKey;
/** /**
* nacos config context path * context path for nacos config server.
*/ */
private String contextPath; private String contextPath;

View File

@ -1,32 +1,20 @@
{ {"properties": [
"properties": [ {
{ "name": "spring.cloud.nacos.config.encode",
"name": "spring.cloud.nacos.config.server-addr", "type": "java.lang.String",
"type": "java.lang.String", "defaultValue": "UTF-8",
"defaultValue": "", "description": "default encode for nacos config content."
"description": "nacos config server address." },
}, {
{ "name": "spring.cloud.nacos.config.prefix",
"name": "spring.cloud.nacos.config.timeout", "type": "java.lang.String",
"type": "java.lang.Long", "defaultValue": "${spring.application.name}",
"defaultValue": 3000, "description": "the prefix of dataId, nacos config data meta info. dataId = prefix + '-' + ${spring.active.profile} + `-` + ${spring.cloud.nacos.config.content-type}."
"description": "sentinel api port." },
}, {
{ "name": "spring.cloud.nacos.config.content-type",
"name": "spring.cloud.sentinel.dashboard", "type": "java.lang.String",
"type": "java.lang.String", "defaultValue": "properties",
"description": "sentinel dashboard address, won't try to connect dashboard when address is empty." "description": "the content type of nacos config content, only support properties now."
}, }
{ ]}
"name": "spring.cloud.sentinel.filter.order",
"type": "java.lang.Integer",
"defaultValue": "Integer.MIN_VALUE",
"description": "Sentinel filter chain order, will be set to FilterRegistrationBean."
},
{
"name": "spring.cloud.sentinel.filter.urlPatterns",
"type": "java.util.List",
"description": "URL pattern for Sentinel filter, default contains '/*'."
}
]
}

View File

@ -50,8 +50,12 @@
<scope>provided</scope> <scope>provided</scope>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId> <artifactId>spring-boot</artifactId>

View File

@ -44,17 +44,17 @@ import java.util.Objects;
public class NacosDiscoveryProperties { public class NacosDiscoveryProperties {
/** /**
* nacos naming server address * nacos discovery server address
*/ */
private String serverAddr; private String serverAddr;
/** /**
* nacos naming server endpoint * the domain name of a service, through which the server address can be dynamically obtained.
*/ */
private String endpoint; private String endpoint;
/** /**
* nacos naming namespacetodo * namespace, separation registry of different environments.
*/ */
private String namespace; private String namespace;
@ -64,45 +64,45 @@ public class NacosDiscoveryProperties {
private String logName; private String logName;
/** /**
* service name to publish * service name to registry
*/ */
@Value("${spring.cloud.nacos.discovery.service:${spring.application.name:}}") @Value("${spring.cloud.nacos.discovery.service:${spring.application.name:}}")
private String service; private String service;
/** /**
* weights for service instance * weight for service instance, the larger the value, the larger the weight.
*/ */
private float weight = 1; private float weight = 1;
/** /**
* publish to which virtual clusterName * cluster name for nacos server.
*/ */
private String clusterName = "DEFAULT";//todo default value is ? private String clusterName = "DEFAULT";
/** /**
* extra metadata to publish * extra metadata to register.
*/ */
private Map<String, String> metadata = new HashMap<>(); private Map<String, String> metadata = new HashMap<>();
/** /**
* if you just want to subscribe, but don't want to publish your service, set it to * if you just want to subscribe, but don't want to register your service, set it to
* false. * false.
*/ */
private boolean registerEnabled = true; private boolean registerEnabled = true;
/** /**
* The ip address your want to publish for your service instance, needn't to set it if * The ip address your want to register for your service instance, needn't to set it if
* the auto detect ip works well * the auto detect ip works well
*/ */
private String ip; private String ip;
/** /**
* which network interface's ip you want to publish * which network interface's ip you want to register
*/ */
private String networkInterface = ""; private String networkInterface = "";
/** /**
* The port your want to publish for your service instance, needn't to set it if the * The port your want to register for your service instance, needn't to set it if the
* auto detect port works well * auto detect port works well
*/ */
private int port = -1; private int port = -1;
@ -113,12 +113,12 @@ public class NacosDiscoveryProperties {
private boolean secure = false; private boolean secure = false;
/** /**
* access key for nacos discovery * access key for namespace.
*/ */
private String accessKey; private String accessKey;
/** /**
* secret key for nacos discovery * secret key for namespace.
*/ */
private String secretKey; private String secretKey;

View File

@ -0,0 +1,8 @@
{"properties": [
{
"name": "spring.cloud.nacos.discovery.service",
"type": "java.lang.String",
"defaultValue": "${spring.application.name}",
"description": "the service name to register, default value is ${spring.application.name}."
}
]}