|
36 | 36 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
37 | 37 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
38 | 38 | import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
| 39 | +import org.springframework.boot.context.properties.PropertyMapper; |
39 | 40 | import org.springframework.context.annotation.Bean;
|
40 |
| -import org.springframework.util.StringUtils; |
41 | 41 |
|
42 | 42 | /**
|
43 | 43 | * {@link AutoConfiguration Auto-configuration} for Milvus Vector Store.
|
@@ -110,32 +110,15 @@ public MilvusServiceClient milvusClient(MilvusVectorStoreProperties serverProper
|
110 | 110 | .withIdleTimeout(clientProperties.getIdleTimeoutMs(), TimeUnit.MILLISECONDS)
|
111 | 111 | .withAuthorization(clientProperties.getUsername(), clientProperties.getPassword());
|
112 | 112 |
|
113 |
| - if (clientProperties.isSecure() && StringUtils.hasText(clientProperties.getUri())) { |
114 |
| - builder.withUri(clientProperties.getUri()); |
115 |
| - } |
116 |
| - |
117 |
| - if (clientProperties.isSecure() && StringUtils.hasText(clientProperties.getToken())) { |
118 |
| - builder.withToken(clientProperties.getToken()); |
119 |
| - } |
120 |
| - |
121 |
| - if (clientProperties.isSecure() && StringUtils.hasText(clientProperties.getClientKeyPath())) { |
122 |
| - builder.withClientKeyPath(clientProperties.getClientKeyPath()); |
123 |
| - } |
124 |
| - |
125 |
| - if (clientProperties.isSecure() && StringUtils.hasText(clientProperties.getClientPemPath())) { |
126 |
| - builder.withClientPemPath(clientProperties.getClientPemPath()); |
127 |
| - } |
128 |
| - |
129 |
| - if (clientProperties.isSecure() && StringUtils.hasText(clientProperties.getCaPemPath())) { |
130 |
| - builder.withCaPemPath(clientProperties.getCaPemPath()); |
131 |
| - } |
132 |
| - |
133 |
| - if (clientProperties.isSecure() && StringUtils.hasText(clientProperties.getServerPemPath())) { |
134 |
| - builder.withServerPemPath(clientProperties.getServerPemPath()); |
135 |
| - } |
136 |
| - |
137 |
| - if (clientProperties.isSecure() && StringUtils.hasText(clientProperties.getServerName())) { |
138 |
| - builder.withServerName(clientProperties.getServerName()); |
| 113 | + if (clientProperties.isSecure()) { |
| 114 | + PropertyMapper mapper = PropertyMapper.get(); |
| 115 | + mapper.from(clientProperties::getUri).whenHasText().to(builder::withUri); |
| 116 | + mapper.from(clientProperties::getToken).whenHasText().to(builder::withToken); |
| 117 | + mapper.from(clientProperties::getClientKeyPath).whenHasText().to(builder::withClientKeyPath); |
| 118 | + mapper.from(clientProperties::getClientPemPath).whenHasText().to(builder::withClientPemPath); |
| 119 | + mapper.from(clientProperties::getCaPemPath).whenHasText().to(builder::withCaPemPath); |
| 120 | + mapper.from(clientProperties::getServerPemPath).whenHasText().to(builder::withServerPemPath); |
| 121 | + mapper.from(clientProperties::getServerName).whenHasText().to(builder::withServerName); |
139 | 122 | }
|
140 | 123 |
|
141 | 124 | return new MilvusServiceClient(builder.build());
|
|
0 commit comments