|
1 | 1 | /*
|
2 |
| - * Copyright 2023-2024 the original author or authors. |
| 2 | + * Copyright 2023-2025 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
34 | 34 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
35 | 35 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
36 | 36 | import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
| 37 | +import org.springframework.boot.context.properties.PropertyMapper; |
37 | 38 | import org.springframework.context.annotation.Bean;
|
38 |
| -import org.springframework.util.StringUtils; |
39 | 39 |
|
40 | 40 | /**
|
41 | 41 | * {@link AutoConfiguration Auto-configuration} for Milvus Vector Store.
|
@@ -106,32 +106,15 @@ public MilvusServiceClient milvusClient(MilvusVectorStoreProperties serverProper
|
106 | 106 | .withIdleTimeout(clientProperties.getIdleTimeoutMs(), TimeUnit.MILLISECONDS)
|
107 | 107 | .withAuthorization(clientProperties.getUsername(), clientProperties.getPassword());
|
108 | 108 |
|
109 |
| - if (clientProperties.isSecure() && StringUtils.hasText(clientProperties.getUri())) { |
110 |
| - builder.withUri(clientProperties.getUri()); |
111 |
| - } |
112 |
| - |
113 |
| - if (clientProperties.isSecure() && StringUtils.hasText(clientProperties.getToken())) { |
114 |
| - builder.withToken(clientProperties.getToken()); |
115 |
| - } |
116 |
| - |
117 |
| - if (clientProperties.isSecure() && StringUtils.hasText(clientProperties.getClientKeyPath())) { |
118 |
| - builder.withClientKeyPath(clientProperties.getClientKeyPath()); |
119 |
| - } |
120 |
| - |
121 |
| - if (clientProperties.isSecure() && StringUtils.hasText(clientProperties.getClientPemPath())) { |
122 |
| - builder.withClientPemPath(clientProperties.getClientPemPath()); |
123 |
| - } |
124 |
| - |
125 |
| - if (clientProperties.isSecure() && StringUtils.hasText(clientProperties.getCaPemPath())) { |
126 |
| - builder.withCaPemPath(clientProperties.getCaPemPath()); |
127 |
| - } |
128 |
| - |
129 |
| - if (clientProperties.isSecure() && StringUtils.hasText(clientProperties.getServerPemPath())) { |
130 |
| - builder.withServerPemPath(clientProperties.getServerPemPath()); |
131 |
| - } |
132 |
| - |
133 |
| - if (clientProperties.isSecure() && StringUtils.hasText(clientProperties.getServerName())) { |
134 |
| - builder.withServerName(clientProperties.getServerName()); |
| 109 | + if (clientProperties.isSecure()) { |
| 110 | + PropertyMapper mapper = PropertyMapper.get(); |
| 111 | + mapper.from(clientProperties::getUri).whenHasText().to(builder::withUri); |
| 112 | + mapper.from(clientProperties::getToken).whenHasText().to(builder::withToken); |
| 113 | + mapper.from(clientProperties::getClientKeyPath).whenHasText().to(builder::withClientKeyPath); |
| 114 | + mapper.from(clientProperties::getClientPemPath).whenHasText().to(builder::withClientPemPath); |
| 115 | + mapper.from(clientProperties::getCaPemPath).whenHasText().to(builder::withCaPemPath); |
| 116 | + mapper.from(clientProperties::getServerPemPath).whenHasText().to(builder::withServerPemPath); |
| 117 | + mapper.from(clientProperties::getServerName).whenHasText().to(builder::withServerName); |
135 | 118 | }
|
136 | 119 |
|
137 | 120 | return new MilvusServiceClient(builder.build());
|
|
0 commit comments