0

I have Spring Cloud DataFlow v1.3.1.RELEASE running locally, and I've created a small sample 'processor' app to illustrate what I see happening.

The Boot application has two @ConfigurationProperties classes:

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;
    }

}

and 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;
    }

}

I also include a unit test to make sure the BootApplicationConfigurationMetadataResolver is resolving all the whitelisted classes appropriately.

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());
       }
    }
}

The output of the unit test is as expected:

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

However, when I register the Boot application as a 'processor' in Spring Cloud Dataflow, and inspect the registered application, the UI only partially renders the discovered whitelisted properties:

Screenshot

I have a ZIP file of the project source code, but for whatever reason, cannot figure out how to attach it here.

  • I cannot make it working as wll. Could you find a way to do it? I asked my own question here https://stackoverflow.com/questions/59412806/spring-cloud-data-flow-custom-application-properties – marie Dec 23 '19 at 16:38

2 Answers2

1

Inside the file spring-configuration-metadata-whitelist.properties did you add the two classes in the property ?

Example

configuration.classes = org.springframework.cloud.stream.app.file.sink.FileSinkProperties

and

com.anotherpackage.MainConfig.java
petezurich
  • 9,280
  • 9
  • 43
  • 57
0

Both the properties class must be declared in the spring-configuration-metadata-whitelist.properties file. Shell, Dashboard, and REST endpoints should then be able to produce the results consistently.

Here's the same example in action.

Sabby Anandan
  • 5,636
  • 2
  • 12
  • 21
  • Here are the contents of my `sping-configuration-metadata-whitelist.properties` file: `configuration-properties.classes=com.example.demo.DemoApplicationProperties,com.example.demo.DemoApplicationPropertiesTwo` – Channing Jackson Mar 30 '18 at 15:34
  • Looks good. It should be able to work as-is. Is the file under `resources/META-INF` folder? If yes, I'd up for reviewing the project if you can share it with dropbox or elsewhere. – Sabby Anandan Mar 30 '18 at 16:53
  • Also, please check the latest commit [here](https://github.com/sabbyanandan/sandbox/tree/master/channing). If there's >1 property class, you'd have to make sure they have different prefixes. O'wise, the last property class wins. – Sabby Anandan Mar 30 '18 at 18:06