marie
marie

Reputation: 507

Spring cloud data flow custom application properties

I created a custom spring cloud data flow application. I would like to create a stream with it and put some application properties in it, as we can add for the provided application log (0/3 properties): enter image description here

I tried with application.yml file in resources folder:

spring:
  application:
    toto: 'titi'

but it didn't work.

I also tried to create some Properties.class

public class Properties {

    //public static final String PREFIX = "portin";
    private String toto;

    public Properties(String toto) {
        this.toto = toto;
    }

    public Properties() {
    }

    public String getToto() {
        return toto;
    }

    public void setToto(String toto) {
        this.toto = toto;
    }
}

and add the folowing declaration in dataflow-configuration-metadata-whitelist.properties file:

configuration-properties.classes=com.mycompany.Properties but that was not a success and the aplication doesn't have any property.

I couldn't find anything relevant in documentation (I am not English speaking native so I may have misread something).

Thanks for helping

EDIT after moving dataflow-configuration-metadata-whitelist.properties in META-INF folder

the whitelist property files were not under META-INF folder. Now I have this project:

enter image description here

but it doesn't help. The pom.xml is:

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>io.fabric8</groupId>
                <artifactId>docker-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-app-starter-metadata-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>aggregate-metadata</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>aggregate-metadata</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

then I build the application with docker. Is there something docker specific to do then? I could read the documentation but cannot see what is missing on my project

Upvotes: 3

Views: 3226

Answers (3)

Ajay Rathod
Ajay Rathod

Reputation: 51

i have a more or less similar use case, I have built a Custom jdbc kafka jar using prebuilt app, jdbc-source-kafka.

I was using as a jar and and metadata jar separately, whenever i am registering app with these two uri and metadata uri.

i can see the configurable properties whole creating a stream app in UI.

but, i have converted this jar's into docker form including metadata jar which has the meta-inf folder. that option of application of property no more visible. any idea on this.

how to provide meta data URI access to my docker image in SCDF

Upvotes: 0

marie
marie

Reputation: 507

I could do the job thanks to this post: Spring Cloud Dataflow Kubernetes get properties of jar from dockerfile The way I registered the app was wrong. Now, I add the companion metadata URI and it works

Upvotes: 1

Ilayaperumal Gopinathan
Ilayaperumal Gopinathan

Reputation: 4179

For the custom application properties, you can make sure if you follow Spring Boot configuration properties configuration correctly. You can see some of the examples from the out of the box apps here

I am not sure which version of SCDF do you use. If you are on the release before SCDF 2.x, then the name of the whitelist properties needs to be spring-configuration-metadata-whitelist.properties as the whitelist properties file with the name dataflow-configuration-metadata-whitelist.properties is supported only from SCDF 2.x.

Also, make sure to place the whitelist properties file into /META-INF directory under classpath (src/main/resources directory) for example here.

Regarding the documentation, please follow the instructions mentioned here in the SCDF documentation.

Upvotes: 3

Related Questions