I have the following config and java code to map the yml config however the rest, soap and javascript properties are not getting mapped.
Tried the approach given here in accepted answer but no luck https://stackoverflow.com/a/50410542/10644550
Spring boot version: spring-boot-2.7.0
Any help would be appreciated.
application.yml
bpmn:
prop:
rest:
- http-rest-service
- REST
soap:
- http-soap-service
- SOAP
javascript:
- JAVASCRIPT
- JS-script-worker
test1: 1235
Java code:
package com.example.orchestration.properties;
import lombok.Data;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.List;
import java.util.Set;
@Configuration
@Component
@ConfigurationProperties(prefix = "bpmn.prop")
@PropertySource("application.yml")
@Setter
public class BpmnProperties {
//@Value("${rest}")
Set<String> rest;
//@Value("soap")
Set<String> soap;
// @Value("javascript")
Set<String> javascript;
String test1;
public boolean isRest(String str){
return rest.contains(str);
}
public boolean isSoap(String soap){
return this.soap.contains(soap);
}
public boolean isJs(String js){
return javascript.contains(js);
}
@PostConstruct
public void init(){
System.out.println(rest);
System.out.println("test "+test1);
}
}