fix:fix context configuration NPE when using standalone polaris

pull/15/head 1.1.2.Hoxton.SR9
SkyeBeFreeman 3 years ago
parent 314fd93cab
commit e096d4496a

@ -37,6 +37,8 @@ Spring Cloud Tencent 使用 Maven 来构建,最快的使用方式是将本项
### 如何引入依赖
在 dependencyManagement 中添加如下配置,然后在 dependencies 中添加自己所需使用的依赖即可使用。
与此同时您需要注意Spring Cloud Tencent对应的Spring Cloud版本进而对应到的Spring Boot版本。
例如Spring Cloud Tencent的1.0.1.Hoxton.SR9对应Spring Cloud Hoxton版本需要使用Spring Boot 2.3.x。
````
<dependencyManagement>
@ -67,6 +69,8 @@ Example 列表:
- [Polaris Gateway Example](spring-cloud-tencent-examples/polaris-gateway-example/README-zh.md)
更加详细的使用方法参考 [使用polaris-java](https://github.com/polarismesh/website/blob/main/docs/zh/doc/%E5%BF%AB%E9%80%9F%E5%85%A5%E9%97%A8/%E4%BD%BF%E7%94%A8polaris-java.md).
## 版本号规范
采取与Spring Cloud大版本号相关的版本策略。

@ -39,7 +39,9 @@ When all the steps are finished, the project will be installed in local Maven re
### How to Introduce Dependency
Add the following configurations n dependencyManagement, then add the dependencies you need.
Add the following configurations in dependencyManagement, then add the dependencies you need.
At the same time, you need to pay attention to the Spring Cloud version corresponding to Spring Cloud Tencent, and then the corresponding Spring Boot version.
For example, Spring Cloud Tencent's 1.0.1.Hoxton.SR9 corresponds to the Spring Cloud Hoxton version and requires Spring Boot 2.3.x.
````
<dependencyManagement>
@ -70,6 +72,8 @@ Example List:
- [Polaris Gateway Example](spring-cloud-tencent-examples/polaris-gateway-example/README.md)
For more features, please refer to [使用polaris-java](https://github.com/polarismesh/website/blob/main/docs/zh/doc/%E5%BF%AB%E9%80%9F%E5%85%A5%E9%97%A8/%E4%BD%BF%E7%94%A8polaris-java.md).
### Version Standard
We use a version policy related to Spring Cloud's major version number.

@ -71,7 +71,7 @@
<properties>
<!-- Project revision -->
<revision>1.1.1.Hoxton.SR9</revision>
<revision>1.1.2.Hoxton.SR9</revision>
<!-- Spring Cloud -->
<spring.cloud.version>Hoxton.SR9</spring.cloud.version>

@ -62,8 +62,8 @@
</developers>
<properties>
<revision>1.1.1.Hoxton.SR9</revision>
<polaris.version>1.1.1</polaris.version>
<revision>1.1.2.Hoxton.SR9</revision>
<polaris.version>1.2.0</polaris.version>
<tomcat.version>10.0.0-M6</tomcat.version>
<powermock.version>2.0.0</powermock.version>

@ -47,6 +47,17 @@ spring:
address: ${protocol}://${ip}:${port}
```
3. 如果您部署的是单机版Polaris您需要在项目中添加如下Polaris参数.../resources/polaris.yml
```yaml
global:
system:
discoverCluster:
sameAsBuiltin: true
healthCheckCluster:
sameAsBuiltin: true
```
更加详细的使用方法参考 [Polaris Discovery Example](../../../../spring-cloud-tencent-examples/polaris-discovery-example/README-zh.md)。
## 拓展使用

@ -24,7 +24,7 @@ For configuration, please refer to [Polaris CircuitBreaker](https://github.com/p
This chapter will explain how to use Polaris in Spring Cloud project in the simplest way.
CircuitBreaker's feature. Before starting MicroService, one needs to launch Polaris. Please refer to [Polaris Getting Started](https://github.com/PolarisMesh/polaris#getting-started).
1. you can add ```spring-cloud-starter-tencent-polaris-circuitbreaker``` 's dependencies in your project to use CircuitBreaker features. For example, in Maven's project, add listed configurations in pom:
1. You can add ```spring-cloud-starter-tencent-polaris-circuitbreaker``` 's dependencies in your project to use CircuitBreaker features. For example, in Maven's project, add listed configurations in pom:
```XML
<dependency>

@ -24,7 +24,7 @@ CLB supports qualified packet forwarding in the service instance. Through set ba
This chapter will explain how to use Polaris Discovery's features in the Spring Cloud project. Before starting MicroService, one needs to launch Polaris. Please refer to [Polaris Getting Started](https://github.com/PolarisMesh/polaris#getting-started).
1. you can add ```spring-cloud-starter-tencent-polaris-discovery```'s 's dependencies in your project to use Polaris's service registration and discovery feature. For example, in Maven's project, add listed configurations in pom:
1. You can add ```spring-cloud-starter-tencent-polaris-discovery```'s dependencies in your project to use Polaris's service registration and discovery feature. For example, in Maven's project, add listed configurations in pom:
```XML
<dependency>
@ -44,6 +44,17 @@ spring:
server-addr: ${ip}:${port}
```
3. If you deploy standalone Polaris, you should add this polaris configuration in your project(.../resources/polaris.yml):
```yaml
global:
system:
discoverCluster:
sameAsBuiltin: true
healthCheckCluster:
sameAsBuiltin: true
```
For further instructions, please refer to [Polaris Discovery Example](../../../../spring-cloud-tencent-examples/polaris-discovery-example/README.md).
## Extended Application

@ -22,7 +22,7 @@ This chapter will explain how to use Spring Cloud Tencent Polaris Gateway's feat
Before starting MicroService, one needs to launch Polaris.
Please refer to [Polaris Getting Started](https://github.com/PolarisMesh/polaris#getting-started).
1. you can add ```spring-cloud-tencent-polaris-gateway``` in your project to use Polaris's microservice gateway extension features
1. You can add ```spring-cloud-tencent-polaris-gateway``` in your project to use Polaris's microservice gateway extension features
(meaning you still need to add microservice gateway modules yourself, such as zuul, spring-cloud-gateway).
For example, in Maven's project, add listed configurations in pom:

@ -24,7 +24,7 @@ Default introduce spring-cloud-starter-tencent-polaris-ratelimit dependencies ca
This chapter will explain how to use Polaris RateLimit in Spring Cloud project with the easiest way. Before starting MicroService, one needs to launch Polaris. Please refer to [Polaris Getting Started](https://github.com/PolarisMesh/polaris#getting-started).
1. you can add ```spring-cloud-starter-tencent-polaris-ratelimit```s dependencies in your project to use the rate limit feature. For example, in Maven's project, add listed:
1. You can add ```spring-cloud-starter-tencent-polaris-ratelimit```s dependencies in your project to use the rate limit feature. For example, in Maven's project, add listed:
```XML
<dependency>

@ -6,7 +6,7 @@ spring:
name: DiscoveryCalleeService
cloud:
polaris:
address: grpc://127.0.0.1:8081
address: grpc://127.0.0.1:8091
consul:
port: 8500
host: 127.0.0.1

@ -0,0 +1,6 @@
global:
system:
discoverCluster:
sameAsBuiltin: true
healthCheckCluster:
sameAsBuiltin: true

@ -6,7 +6,7 @@ spring:
name: DiscoveryCallerService
cloud:
polaris:
address: grpc://127.0.0.1:8081
address: grpc://127.0.0.1:8091
consul:
port: 8500
host: 127.0.0.1

@ -0,0 +1,6 @@
global:
system:
discoverCluster:
sameAsBuiltin: true
healthCheckCluster:
sameAsBuiltin: true

@ -6,4 +6,4 @@ spring:
name: GatewayCalleeService
cloud:
polaris:
address: grpc://127.0.0.1:8081
address: grpc://127.0.0.1:8091

@ -6,7 +6,7 @@ spring:
name: GatewayScgService
cloud:
polaris:
address: grpc://127.0.0.1:8081
address: grpc://127.0.0.1:8091
tencent:
metadata:
content:

@ -6,7 +6,7 @@ spring:
name: GatewayZuulService
cloud:
polaris:
address: grpc://127.0.0.1:8081
address: grpc://127.0.0.1:8091
tencent:
metadata:
content:

@ -63,6 +63,7 @@ public class PolarisContextProperties {
protected Configuration configuration() {
ConfigurationImpl configuration = (ConfigurationImpl) ConfigAPIFactory
.defaultConfig(ConfigProvider.DEFAULT_CONFIG);
configuration.setDefault();
String defaultHost = getHost();
configuration.getGlobal().getAPI().setBindIP(defaultHost);
Collection<PolarisConfigModifier> modifiers = modifierList;

Loading…
Cancel
Save