我正在尝试在我的 Micronaut 应用程序中使用 jOOQ,并将 jOOQ DSLContext 作为注入的 bean 自动提供给我的构造函数,但它找不到 bean。
我已经在 application.yml 中配置了数据源以连接到我的 postgres 数据库,并声明了我的构造函数如下:
@Singleton
public class RepositoryImpl implements Repository
{
private final DSLContext context;
public RepositoryImpl(DSLContext context)
{
this.context = context;
}
}
Run Code Online (Sandbox Code Playgroud)
和我的 application.yml 为:
datasources:
default:
url: "jdbc:postgresql://localhost:5432/my_db"
username: "user"
password: "password"
driver-class-name: "org.postgresql.Driver"
Run Code Online (Sandbox Code Playgroud)
我在 build.gradle 中包含了以下依赖项
compile 'io.micronaut.configuration:micronaut-jooq'
runtime 'org.postgresql:postgresql:42.2.4'
Run Code Online (Sandbox Code Playgroud)
我希望我可以访问 DSLContext 并在我的 RepositoryImpl 类中编写查询,但是在尝试使用实现类时,代码失败并出现以下异常:
Caused by: io.micronaut.context.exceptions.NoSuchBeanException: No bean of type [org.jooq.DSLContext] exists. Make sure the bean is not disabled by bean requirements (enable …Run Code Online (Sandbox Code Playgroud)