Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge config.properties and application.properties #76

Merged
merged 4 commits into from
Nov 7, 2024
Merged

Conversation

palagdan
Copy link
Collaborator

Resolves #75

@palagdan palagdan force-pushed the 75-merge-config branch 2 times, most recently from 1a19f09 to 07dd672 Compare October 14, 2024 08:26
@palagdan
Copy link
Collaborator Author

palagdan commented Oct 14, 2024

@blcham

I have merged config.properties and application.properties into application.yml because I believe YAML is more readable than properties files. If you have a different opinion, I'd be happy to discuss it.

In the tests, I refactored configuration.properties to application.properties because it is not possible to convert it to YAML. The TestFormGenPersistenceFactory and TestPersistenceFactory classes use the annotation @PropertySource("classpath:application.properties"), which does not work with YAML files (source).

The solution might be to create a base test class with the @SpringBootTest annotation to easily load YAML configuration files. I tried this, but I encountered many errors related to the inability to create some beans and load a context, etc. Maybe it is a problem for another ticket, to refactor record-manager tests configuration.

@palagdan palagdan requested a review from blcham October 14, 2024 08:53
@blcham
Copy link

blcham commented Oct 16, 2024

Please use application.yml in tests as well.

Have a look here for inspiration:
https://github.com/kbss-cvut/termit/blob/master/src/test/resources/application.yml

@palagdan
Copy link
Collaborator Author

@blcham

Since there are issues with the YAML files during testing, I suggest using application.properties in the src/ directory as well. There is no significant difference between .yml and .properties, except for syntax and parsers. Spring generally prefers .properties, especially when working with certain annotations like @propertysource and @TestPropertySource.

@blcham
Copy link

blcham commented Nov 7, 2024

@palagdan I did some investigation, and I came to the conclusion that .yml is a better choice mainly due to readability as we have quite many properties now. On the other hand, it is already implemented here as application.properties, so let's merge it and we will consider it someday later :), after we get rid of @PropertySource in favor of @ConfigurationProperties+@EnableConfigurationProperties.


Summary of my investigation:

Pros:

  • more readable for bigger configuration like in RM
  • supports not only key-value pair, but also map, list & scalar type values

Cons:

  • YAML files can’t be loaded via the @propertysource annotation. So in the case that you need to load values that way, you need to use a properties file.
  • .properties files are simpler but really spread only in Java community, so i do not consider it that big advantage compared to .yml that is wide-spread in other comunities (e.g. python)

@blcham blcham merged commit 006df20 into main Nov 7, 2024
2 checks passed
@blcham blcham deleted the 75-merge-config branch November 7, 2024 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Merge config.properties and application.properties
2 participants