1

I migrated a Spring-Cloud-Function to use Functional Bean Registration. I can register the Function that contains my application logic. However my logic should be able to autowire a dynamodbRepository which I currently defined like this:

@EnableScan
public interface BookRepository extends CrudRepository<CodingTip, String> {

        List<Book> findAllByAuthor(String author);
}

Since I am not scanning for beans anymore no bean is created of type BookRepository. This means that I have to register it myself. But I do not want to define the implementations of all the CRUD methods.

Currently I could write:

context.registerBean("repository", BookRepository.class, () -> new BookRepository(){ ... });

How would I register the BookRepository bean while still maintaining the advantages of all the CRUD methods being implemented for me?

Marko Previsic
  • 1,820
  • 16
  • 30
xtra
  • 1,957
  • 4
  • 22
  • 40
  • you can use ``@ComponentScan(basePackages ="com.yours.repos")`` to load all your components(including CrudRepository) in this directory into spring bean container. – Wang Kenneth Jun 29 '19 at 09:33

1 Answers1

1

Check out this incubator project called Spring Fu. Although it is written in Kotlin, it might help you find a way to do this. Take a look here to see how Sébastien did it with a MongoDB database. Creating a DynamoDB client and an implementation instead of using an annotated interface would be the way forward I guess.

Hope that helps! :)

TYsewyn
  • 562
  • 2
  • 9