BAEL-3777: Fixed some spring init issues

This commit is contained in:
Sorin Zamfir 2020-01-27 21:14:55 +02:00
parent a1837550e8
commit 8144040512
4 changed files with 16 additions and 1 deletions

View File

@ -3,11 +3,22 @@ package com.baeldung.dddhexagonalspring.infrastracture.repository;
import java.util.Optional; import java.util.Optional;
import java.util.UUID; 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.Order;
import com.baeldung.dddhexagonalspring.domain.repository.OrderRepository; import com.baeldung.dddhexagonalspring.domain.repository.OrderRepository;
@Component
public class CassandraDbOrderRepository implements OrderRepository { public class CassandraDbOrderRepository implements OrderRepository {
private final SpringDataCassandraOrderRepository orderRepository;
@Autowired
public CassandraDbOrderRepository(SpringDataCassandraOrderRepository orderRepository) {
this.orderRepository = orderRepository;
}
@Override @Override
public Optional<Order> findById(UUID id) { public Optional<Order> findById(UUID id) {
// TODO Auto-generated method stub // TODO Auto-generated method stub

View File

@ -3,12 +3,14 @@ package com.baeldung.dddhexagonalspring.infrastracture.repository;
import com.baeldung.dddhexagonalspring.domain.Order; import com.baeldung.dddhexagonalspring.domain.Order;
import com.baeldung.dddhexagonalspring.domain.repository.OrderRepository; import com.baeldung.dddhexagonalspring.domain.repository.OrderRepository;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Optional; import java.util.Optional;
import java.util.UUID; import java.util.UUID;
@Component @Component
@Primary
public class MongoDbOrderRepository implements OrderRepository { public class MongoDbOrderRepository implements OrderRepository {
private final SpringDataMongoOrderRepository orderRepository; private final SpringDataMongoOrderRepository orderRepository;

View File

@ -3,9 +3,11 @@ package com.baeldung.dddhexagonalspring.infrastracture.repository;
import java.util.UUID; import java.util.UUID;
import org.springframework.data.cassandra.repository.CassandraRepository; import org.springframework.data.cassandra.repository.CassandraRepository;
import org.springframework.stereotype.Repository;
import com.baeldung.dddhexagonalspring.domain.Order; import com.baeldung.dddhexagonalspring.domain.Order;
@Repository
public interface SpringDataCassandraOrderRepository extends CassandraRepository<Order, UUID>{ public interface SpringDataCassandraOrderRepository extends CassandraRepository<Order, UUID>{
} }

View File

@ -4,7 +4,7 @@ spring.data.mongodb.database=order-database
spring.data.mongodb.username=order spring.data.mongodb.username=order
spring.data.mongodb.password=order spring.data.mongodb.password=order
spring.data.cassandra.keyspaceName=order-database spring.data.cassandra.keyspaceName=order_database
spring.data.cassandra.username=cassandra spring.data.cassandra.username=cassandra
spring.data.cassandra.password=cassandra spring.data.cassandra.password=cassandra
spring.data.cassandra.contactPoints=localhost spring.data.cassandra.contactPoints=localhost