Add support for collection properties in ApplicationProperties#1759
Add support for collection properties in ApplicationProperties#1759rodmibielli wants to merge 4 commits intospring-io:mainfrom
Conversation
Signed-off-by: rodmibielli <rodrigo.mibielli@gmail.com>
For properties that can consume a list, that might be OK. However, for properties that should only have a single value, it sounds like a step in the wrong direction. Configuring twice a property with a scalar value will no longer fail. Instead, you'll end up with something like What's the use case for configuring the same property in two different places in an additive manner? I think it would be more robust if the code configuring the property, which has more context and knows that it's a list, dealt with combining the values. |
Use case:
Okay, it could be solved externally and it would be easier if ApplicationProperties had implemented methods such as contains(String key) and get(String key) (both of them). Why it does not have them? |
|
I agree with @wilkinsona . The changes to write lists are fine, but I don't like the automatic merging for properties into a list.
Because we haven't had a need for them. But I'm happy to add them. |
This is great! Thank you! |
...I was thinking here... wouldn´t be possible to create a new method merge(ApplicationProperties other) at ApplicationProperties so it merges other application properties with this object and then the merging properties with same key would apply instead of using the add method? I better you that there are more people facing the same problem...just an opinion... |
|
We can't just automatically merge all properties into a list of properties - some properties are lists, some are scalar values. Initializr doesn't know this, the caller using the We could think about an API design which distinguishes between scalar values and list properties - the former doesn't allow duplicate values, while the latter would automatically append to the list IFF the property has been added as a list property in the first place. However, I wouldn't do that in this PR. This PR should focus on writing properties of type Do you want to remove the automatic merging part or should I do this when polishing this PR? |
Ok, for now contains and get methods work for me. |
|
Thanks for the discussion and clarification. I'm happy to remove the automatic merging behavior and focus this PR on supporting list properties as suggested. The contains/get methods should be sufficient to handle the use case externally. Please let me know if there are any additional changes you'd like me to make. |
Also either set or remove methods in order to replace or remove/add the old values. Thank you. |
|
@rodmibielli Something is off with the git commits. This PR includes the commit 4a8e70c, which has nothing to do with the PR. Additionally, the commit b178bf5, which implements the feature we want, is a merge commit, which doesn't seem right:
Could you please fix the PR? Thanks! |
|
@rodmibielli never mind, sorry for the ping. I managed to transform the merge commit to a "normal" commit with some git fu. |
|
Great! Thank you!
Rodrigo.
…-------------------------------------------------------------------------------------------------
"Um país se faz com homens e livros" - Monteiro Lobato.
Em ter., 3 de mar. de 2026, 07:58, Moritz Halbritter <
***@***.***> escreveu:
*mhalbritter* left a comment (spring-io/initializr#1759)
<#1759 (comment)>
@rodmibielli <https://github.com/rodmibielli> never mind, sorry for the
ping. I managed to transform the merge commit to a "normal" commit with
some git fu.
—
Reply to this email directly, view it on GitHub
<#1759 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACY5DUNC4TWZ26LON6FBAU34O23F5AVCNFSM6AAAAACV6UK2UGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTSOJQGI2DCMJRGE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
Sorry @rodmibielli , one more thing. The commit b178bf5 is missing the Signed-off-by trailer. Can you please add it so that we have a good DCO? |
Signed-off-by: rodmibielli <rodrigo.mibielli@gmail.com>
|
Sorry for that. Please, check now if the commit has been sign-off.
Em ter., 3 de mar. de 2026 às 08:12, Moritz Halbritter <
***@***.***> escreveu:
… *mhalbritter* left a comment (spring-io/initializr#1759)
<#1759 (comment)>
Sorry @rodmibielli <https://github.com/rodmibielli> , one more thing. The
commit b178bf5
<b178bf5>
is missing the Signed-off-by trailer. Can you please add it so that we have
a good DCO?
—
Reply to this email directly, view it on GitHub
<#1759 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACY5DUP6PGGH6QETSDZJFZ34O242LAVCNFSM6AAAAACV6UK2UGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTSOJQGMYTEMJUGE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
--
Rodrigo.
-------------------------------------------------------------------------------------------------
"Um país se faz com homens e livros" - Monteiro Lobato.
|
Signed-off-by: rodmibielli <rodrigo.mibielli@gmail.com> See gh-1759
|
Thanks @rodmibielli ! |
|
I created #1760 for the read / remove methods. |

I have faced a real problem when I tried to merge two distinct values with same key at
application.yaml(orapplication.properties).I have got an assertion error denying adding the same property key with its value more than once.
So, I have modified the application initializr code in order to be more generic: it does not have the strict rule of adding application property key with its value only once anymore: if you add more than once, at
application.propertiesit will join the distinct values with comma; atapplication.yaml, it will create an array structure for the property (check the tests code as example).This solution really worked for me as I think it will also work for a lot of people.