简体   繁体   中英

Spring functional bean registration of @Repository interface

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?

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! :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM