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

Location of application.properties #19

Open
JayAhn2 opened this issue Nov 2, 2020 · 5 comments
Open

Location of application.properties #19

JayAhn2 opened this issue Nov 2, 2020 · 5 comments

Comments

@JayAhn2
Copy link

JayAhn2 commented Nov 2, 2020

Hi Tom,

First of all, Thanks for the nice demo project for hexagonal architecture. :)
This project is the best implementations I've ever seen!

I'm quite a newbie on Spring Boot, so my question would be quite silly.
As I see this project, I cannot find application.properties or application.yml. I guess this should exist if I want to add some configuration like DB connection.

Could you let me know why configuration file is missing in this project?

Thanks!

@dhasilin
Copy link

dhasilin commented Nov 5, 2020

Also it is interesting how module *.properties files collaborate.
There are some issues around @ConditionalOnProperty with different properties files.

@amithksm
Copy link

Same suggestion/issue as posted by JayAhn2. I intend to view the H2 database via localhost:8080/h2-console

@RuneMolin
Copy link

RuneMolin commented Nov 15, 2020

Properties, such as those that controls what database to use, are a Spring Boot feature and not relevant for individual applications to define. You can read more about them here

Spring Boot will default to an in-memory H2 database if nothing else is defined.

Also, it is best practice, per 12-factor apps not to allow an application to provide any sort of configuration, but expect the application to always be externally configured. Spring Boot provides many options for doing this, which you can study here

@thombergs
Copy link
Owner

@JayAhn2 @amithksm @RuneMolin thanks for the discussion!

Here are my 2 cents:

  • things like database connections and other configuration parameters can be configured in application-<PROFILE>.yml or application-<PROFILE>.properties
  • it's totally fine to bake these files into the application as I have done here just now, but any secrets should be passed as environment parameters or retrieved from some secret store at runtime
  • multiple modules would share the same application.yml file, as there is only one Spring Boot application. But you could prefix them with different prefixes, like I used the prefix buckpal in BuckPalCoinfigurationProperties

@dhasilin
Copy link

Got it, it generally you suggestion is to stick with one property file.

We end up with same approach, it's just not very "clean" when you have interchangeable plugins (based on client environment).

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

No branches or pull requests

5 participants