I have divided my project into different modules: api, application, domain, and infrastructure. The main class resides in the api module, while the database configuration is in the infrastructure module. Is it possible to configure a database connection if I run the project from the api module, which is different from where the database configuration is located?
spring:
datasource:
url: jdbc:postgresql://localhost:5432/app
username: app_user
password: Zaq
driver-class-name: org.postgresql.Driver
jpa:
hibernate:
ddl-auto: create
show-sql: true
I've set up the dependencies as follows: api -> application -> infrastructure. I encountered an error when trying this setup, so I'm wondering if it's even possible.
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
Action:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
Process finished with exit code 1
However, when I moved the database configuration to the api module, everything worked fine.