diff --git a/ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/repository/cassandra/SpringDataCassandraOrderRepository.java b/ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/repository/cassandra/SpringDataCassandraOrderRepository.java index ca460fb2c7..3c89bd1b23 100644 --- a/ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/repository/cassandra/SpringDataCassandraOrderRepository.java +++ b/ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/repository/cassandra/SpringDataCassandraOrderRepository.java @@ -5,8 +5,6 @@ import java.util.UUID; import org.springframework.data.cassandra.repository.CassandraRepository; import org.springframework.stereotype.Repository; -import com.baeldung.dddhexagonalspring.domain.Order; - @Repository public interface SpringDataCassandraOrderRepository extends CassandraRepository{ diff --git a/ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/repository/mongo/MongoDbOrderRepository.java b/ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/repository/mongo/MongoDbOrderRepository.java index f5d7b8f6c1..e14cb88f5a 100644 --- a/ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/repository/mongo/MongoDbOrderRepository.java +++ b/ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/repository/mongo/MongoDbOrderRepository.java @@ -1,14 +1,14 @@ package com.baeldung.dddhexagonalspring.infrastracture.repository.mongo; -import com.baeldung.dddhexagonalspring.domain.Order; -import com.baeldung.dddhexagonalspring.domain.repository.OrderRepository; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Primary; -import org.springframework.stereotype.Component; - import java.util.Optional; import java.util.UUID; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.baeldung.dddhexagonalspring.domain.Order; +import com.baeldung.dddhexagonalspring.domain.repository.OrderRepository; + @Component public class MongoDbOrderRepository implements OrderRepository { diff --git a/ddd/src/main/resources/ddd-layers.properties b/ddd/src/main/resources/ddd-layers.properties index d0ad343b66..412c24eef7 100644 --- a/ddd/src/main/resources/ddd-layers.properties +++ b/ddd/src/main/resources/ddd-layers.properties @@ -1,3 +1,4 @@ +spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration spring.data.mongodb.host=localhost spring.data.mongodb.port=27017 spring.data.mongodb.database=order-database diff --git a/ddd/src/test/resources/com/baeldung/dddhexagonalspring/README.md b/ddd/src/test/resources/com/baeldung/dddhexagonalspring/README.md index e0337498fc..1355514a3d 100644 --- a/ddd/src/test/resources/com/baeldung/dddhexagonalspring/README.md +++ b/ddd/src/test/resources/com/baeldung/dddhexagonalspring/README.md @@ -4,4 +4,6 @@ To run this project, follow these steps: * Run the application database by executing `docker-compose up` in this directory. * Launch the Spring Boot Application (DomainLayerApplication). -* By default, application will connect to this database (configuration in *ddd-layers.properties*) \ No newline at end of file +* By default, the application will connect to the one of the two databases (configuration in *ddd-layers.properties*) + * check `CassandraDbOrderRepository.java` and `MongoDbOrderRepository.java` + * switch between the databases by making one of the above beans primary using the `@Primary` annotation \ No newline at end of file