I've a properties
file in which the values are comma separated. I'm able to get the values as Object
as below. Could anyone please tell me how to separate the values and get it in String.
.properties
key-1 = value1,value11
key-2 = value2,value22
key-3 = value3,value33
key-4 = value4,value44
Code
@PropertySource( value = "classpath:test1.properties", name = "test1" )
AbstractEnvironment ae = (AbstractEnvironment)env;
org.springframework.core.env.PropertySource test1Source =
ae.getPropertySources().get("test1");
Properties propsTest1 = (Properties)test1Source.getSource();
for(Object key : propsTest1.keySet()){
System.out.println("Properties file======> propsTest1.get(key));
}
You can try something like below.
You can use
@Value
annotation with@PropertySource
to get the value of a property. Also, you can use Spring Expression to split it into list, e.g.:This would give you the list of all the values configured against
key-1
..properties
Code
Or you can use:
Code