在使用Spring Boot 2.1.1.RELEASE配置JOOQ 3.9.6时出现以下错误。
错误:“没有可用的'org.jooq.Configuration'类型的合格Bean:预计至少有1个有资格成为自动装配候选者的Bean”
在application.properties中:
spring.datasource.url=jdbc:mysql://xyz/vzdb
spring.datasource.username=username
spring.datasource.password=password
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jooq.sql-dialect=MySQL
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
在build.gradle文件中:
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath 'nu.studer:gradle-jooq-plugin:1.0.5'
classpath 'mysql:mysql-connector-java:5.1.+'
classpath 'com.google.gms:google-services:3.0.0'
}
apply plugin: 'nu.studer.jooq'
compile('org.jooq:jooq:3.9.6')
jooq {
vizerto(sourceSets.main) {
jdbc {
driver = 'com.mysql.jdbc.Driver'
url = 'jdbc:mysql://xyz:3306/vzdb
user = 'username'
password = 'password'
schema = 'dbname'
}
generator {
name = 'org.jooq.util.DefaultGenerator'
strategy {
name = 'org.jooq.util.DefaultGeneratorStrategy'
}
database {
name = 'org.jooq.util.mysql.MySQLDatabase'
inputSchema = 'dbname'
// ...
}
generate {
relations = true
deprecated = false
records = true
pojos = true
immutablePojos = false
// fluentSetters = true
daos = true
validationAnnotations = true
}
target {
packageName = 'com.user.domains.core'
directory = 'src/main/java'
}
}
}
}