【发布时间】:2018-03-23 19:21:08
【问题描述】:
我在本地运行 Spring Cloud DataFlow v1.3.1.RELEASE,我创建了一个小型示例“处理器”应用程序来说明我看到的情况。
Boot 应用程序有两个@ConfigurationProperties 类:
DemoApplicationProperties:
@ConfigurationProperties
@Validated
public class DemoApplicationProperties {
/**
* The first name of the person.
*/
private String firstName;
/**
* The last name of the person.
*/
private String lastName;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}
和 DemoApplicationPropertiesTwo:
@ConfigurationProperties
@Validated
public class DemoApplicationPropertiesTwo {
/**
* The person's middle name.
*/
private String middleName;
/**
* The date of birth.
*/
private String birthdate;
public String getMiddleName() {
return middleName;
}
public void setMiddleName(String middleName) {
this.middleName = middleName;
}
public String getBirthdate() {
return birthdate;
}
public void setBirthdate(String birthdate) {
this.birthdate = birthdate;
}
}
我还包含一个单元测试,以确保 BootApplicationConfigurationMetadataResolver 正确解析所有列入白名单的类。
public class WhiteListTests {
private BootApplicationConfigurationMetadataResolver metadataResolver;
@Test
public void testMetadataResolver() {
metadataResolver = new BootApplicationConfigurationMetadataResolver(this.getClass().getClassLoader());
Resource app = new FileSystemResource(".\\target\\classes\\");
List<ConfigurationMetadataProperty> list = metadataResolver.listProperties(app);
for(ConfigurationMetadataProperty listItem : list) {
StringBuilder sb = new StringBuilder();
sb.append(listItem.getId() + ": " + listItem.getName() + " :: " + listItem.getType());
System.out.println(sb.toString());
}
}
}
单元测试的输出如预期:
birthdate: birthdate :: java.lang.String
middle-name: middle-name :: java.lang.String
first-name: first-name :: java.lang.String
last-name: last-name :: java.lang.String
但是,当我在 Spring Cloud Dataflow 中将 Boot 应用程序注册为“处理器”并检查注册的应用程序时,UI 仅部分呈现发现的列入白名单的属性:
我有一个项目源代码的 ZIP 文件,但由于某种原因,无法弄清楚如何在此处附加。
【问题讨论】:
-
我无法让它正常工作。你能找到一种方法吗?我在这里问了我自己的问题stackoverflow.com/questions/59412806/…