Spring cloud data flow custom application properties

岁酱吖の 提交于 2020-01-10 06:09:57

问题


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):

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:

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


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/59412806/spring-cloud-data-flow-custom-application-properties

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!