我在本地运行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
但是,当我将Boot应用程序注册为&#39;处理器&#39;在Spring Cloud Dataflow中,并检查已注册的应用程序,UI仅部分呈现发现的白名单属性:
我有一个项目源代码的ZIP文件,但无论出于何种原因,都无法弄清楚如何将其附加到此处。
答案 0 :(得分:1)
在文件spring-configuration-metadata-whitelist.properties
中你是否在属性中添加了两个类?
实施例
configuration.classes = org.springframework.cloud.stream.app.file.sink.FileSinkProperties
和
com.anotherpackage.MainConfig.java
答案 1 :(得分:0)
属性类必须在spring-configuration-metadata-whitelist.properties
文件中声明。然后,Shell,Dashboard和REST端点应该能够始终如一地生成结果。
这是action中的相同示例。