有没有办法告诉JDBI,我想在整个应用程序中使用一个特定的插件(在我的例子中是SqlObjectPlugin),而不必在每次使用时重新指定?在我的应用程序代码中,我有以下内容:
var jdbi = Jdbi.create(dataSource);
jdbi.installPlugin(new SqlObjectPlugin()); // <== I want to make this part DRY我厌倦了在我的代码中重复第二条样板行。
给JDBI :我完全喜欢这个产品!( thx!)
发布于 2022-09-08 10:23:48
您有两个选项,哪个选项最好取决于应用程序的代码:
Jdbi一次并在任何地方重用它(使用DI、静态单例等)org.jdbi.v3.core.Jdbi#installPlugins,根据文档,org.jdbi.v3.core.Jdbi#installPlugins是uses the ServiceLoader API to detect and install plugins automagically. Some people consider this feature dangerous; some consider it essential -- use at your own risk。但是,每次都需要调用此方法。https://stackoverflow.com/questions/73642440
复制相似问题