简体   繁体   中英

How to create spring boot shared library for DAO implementations

We received a requirement where we have to build a modularized app compound of multiple shared libraries that would be used by apps that provides graphql queries to expose these shared libraries operations.

One of this shared libraries is the "core" jar that should contain all the DAO implementations (create, update, delete, read entities). However, this core won't have any REST nor running entry point.

Later, this core jar will be added as a maven dependency by the graphql app that would expose all the queries/mutations that would use the shared library.

I could create with any problem the spring boot graphql app and the spring boot core shared library (not as autoconfiguration module) scaffolding and wire the dependencies. However, in the core library project when I started implementing the DAOs I faced the problem that don't know how to test the code since there is no running entry point for it. Also, if I have to create test cases I will have to create the test configuration that should start a running app in order to execute the spring test.

In addition, creating this core library got more complicated since I have to use JOOQ and FlywayDB, so for running test cases I will have to use an embedded Postgresql db.

I'm a bit lost about implementing this requirement, I feel that it would be much more simpler to build a single app with no shared libraries and later on start refactoring it.

Am I missing anything here? How can I execute to debug (and also for testing) a shared library to operate DBs if I have no entry point?

将这个库构建为一个普通的 spring 项目并添加对spring.factories的依赖如何?

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