Skip to content

Commit 7b0b271

Browse files
author
[moon]
committed
修复对配置解析失败的问题
1 parent 9d493a8 commit 7b0b271

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

README-CN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<dependency>
1515
<groupId>plus.jdk.grpc</groupId>
1616
<artifactId>spring-boot-starter-grpc</artifactId>
17-
<version>1.1.01</version>
17+
<version>1.1.02</version>
1818
</dependency>
1919
```
2020

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<dependency>
1414
<groupId>plus.jdk.grpc</groupId>
1515
<artifactId>spring-boot-starter-grpc</artifactId>
16-
<version>1.1.01</version>
16+
<version>1.1.02</version>
1717
</dependency>
1818
```
1919

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>plus.jdk.grpc</groupId>
88
<artifactId>spring-boot-starter-grpc</artifactId>
9-
<version>1.1.01</version>
9+
<version>1.1.02</version>
1010

1111
<name>spring-boot-starter-grpc</name>
1212
<description>spring-boot-starter-grpc</description>

src/main/java/plus/jdk/grpc/client/GrpcClientBeanPostProcessor.java

+14-7
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ private void processMethods(final Class<?> clazz, final Object bean) {
7272
throw new BeanDefinitionStoreException(
7373
"Method " + method + " doesn't have exactly one parameter.");
7474
}
75-
for(Class<?> paramType: paramTypes) {
75+
for (Class<?> paramType : paramTypes) {
7676
if (!AbstractStub.class.isAssignableFrom(paramType)) {
7777
throw new BeanInstantiationException(paramType, "Unsupported grpc stub or channel type");
7878
}
@@ -86,17 +86,24 @@ private void processMethods(final Class<?> clazz, final Object bean) {
8686

8787
protected <T extends AbstractStub<T>>
8888
T processInjectionPoint(final Class<T> injectionType,
89-
final GrpcClient annotation) {
89+
final GrpcClient annotation) {
9090
Environment environment = applicationContext.getEnvironment();
9191
final List<ClientInterceptor> interceptors = interceptorsFromAnnotation(annotation);
9292
String address = annotation.value();
93-
if(!StringUtils.hasText(address)) {
93+
if (!StringUtils.hasText(address)) {
9494
address = properties.getDefaultService();
9595
}
96-
try{
97-
URI uri = URI.create(address);
98-
}catch (Exception e) {
99-
address = environment.getProperty(address);
96+
if (address.startsWith("${") && address.endsWith("}")) {
97+
address = environment.getProperty(address.substring(2, address.length() - 1));
98+
} else {
99+
try {
100+
URI uri = URI.create(address);
101+
if (!uri.isAbsolute()) {
102+
address = environment.getProperty(address);
103+
}
104+
} catch (Exception e) {
105+
address = environment.getProperty(address);
106+
}
100107
}
101108
return grpcSubClientFactory.createStub(injectionType, address, interceptors.toArray(new ClientInterceptor[]{}));
102109
}

0 commit comments

Comments
 (0)