Multi Module Application Database Connection - Spring Boot, Postgres

15 views Asked by At

0

Building an multi module application using Spring Boot, Implementing a hexagonal architecture where I have a domain module, application module and infrastructure module. Each module has a :domain dependency, where I have implemented the models and my business logic, In the application layer I have my controllers, dtos and the main application class where I start the application.

@SpringBootApplication
@ComponentScan({"ez.ndvz.application", "ez.ndvz","ez.ndvz.infrastructure.persistance","ez.ndvz.infrastructure"})
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

}

In my infrastructure module I have another submodule called persistence where I defined my entities and jpa repositories at the same time I have my db connection properties:

spring:
  datasource:
    url: jdbc:postgresql://localhost:5432/booksDB
    username: *********
    password: ****
    driver-class-name: org.postgresql.Driver

    jpa:
      database: POSTGRESQL
      show-sql: true
      hibernate:
        ddl-auto: update
      properties:
        hibernate:
          dialect: org.hibernate.dialect.PostgreSQLDialect

Now when I run the application from my Application Main Class I get the following error:

*************************** 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).

Disconnected from the target VM, address: '127.0.0.1:52985', transport: 'socket*************************** 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).

Disconnected from the target VM, address: '127.0.0.1:52985', transport: 'socket And I get some logs saying : RepositoryConfigurationExtensionSupport : Spring Data JDBC - Could not safely identify store assignment for repository candidate interface ez.ndvz.persistance.repository.ImageRepository; If you want this repository to be a JDBC repository, consider annotating your entities with one of these annotations: org.springframework.data.relational.core.mapping.Table

. for each of my entities

Could It Be That Spring Boot isn't recognizing the application.yaml file in the persistance submodule when starting? How do I fix this Link to the project -> https://github.com/EnisZenuni/Nedviznosti

0

There are 0 answers