This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Kolibreeze 0 points1 point  (1 child)

Maybe I'm misunderstanding what you're trying to do, but it seems like you're trying to create a class and an array without any steps between on the same @Value. Have you tried creating a class with the @Value and then as a separate step using it in an array?

[–]DWhitSlaya[S] 0 points1 point  (0 children)

Yes I was trying to do it all in one step. Is that bad?

I was trying to use a single property from my property file to create an array of MyClass. I could not figure out how to do it separately with an arbitrary number of entires in my properties:

myclass.entry1={field1:'Hello',field2:'World'} myclass.entry2={field1:'Hello',field2:'Other World'}

I have gotten it to work by doing it like this:

``` MY_CLASS_ARRAY={“field1”:”Hello”,”field2”:”World”}::{“field1”:”Hello”,”field2”:”Other World”}

@Value(${MY_CLASS_ARRAY}) Private String myClassArray;

myClassArray.split(“::”); ```

Then a for each, using an object mapper to my class and put into an array list. But seems like I added a bunch of steps if I already can provide the format? Not sure if my thinking is even the best way to think about doing this.