Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server SQL Server 2017-使用Gradle生成JOOQ代码_Sql Server_Gradle_Jooq - Fatal编程技术网

Sql server SQL Server 2017-使用Gradle生成JOOQ代码

Sql server SQL Server 2017-使用Gradle生成JOOQ代码,sql-server,gradle,jooq,Sql Server,Gradle,Jooq,我来自MySQL世界,使用JOOQ生成代码一直是一项简单的任务。输出将很好地符合我的目标包名称。现在我有了这个项目,我需要使用SQL Server 2017作为主数据库。我买了一个JOOQ许可证,并设法让Gradle使用它。Flyway的工作方式很有魅力,但出于某种原因,我一直停留在JOOQ代码生成过程中 我知道在MySQL中,模式和表几乎是一样的,但在SQL Server中不是这样。所有my表都使用DBO作为默认模式,并且位于数据库中my tables目录的根目录下 现在问题来了。当我运行ge

我来自MySQL世界,使用JOOQ生成代码一直是一项简单的任务。输出将很好地符合我的目标包名称。现在我有了这个项目,我需要使用SQL Server 2017作为主数据库。我买了一个JOOQ许可证,并设法让Gradle使用它。Flyway的工作方式很有魅力,但出于某种原因,我一直停留在JOOQ代码生成过程中

我知道在MySQL中,模式和表几乎是一样的,但在SQL Server中不是这样。所有my表都使用DBO作为默认模式,并且位于数据库中my tables目录的根目录下

现在问题来了。当我运行generateJooqSchemaSource时,JOOQ将开始为数据库中的所有表生成代码,包括[master]和[msdb],即使我在连接URL中指定了我的数据库名称。代码生成过程应仅针对我指定的数据库

你知道怎么解决这个问题吗

这是我的gradle构建文件:

buildscript {
    repositories {
        mavenLocal()
        jcenter()
        dependencies {
            classpath 'com.microsoft.sqlserver:mssql-jdbc:7.0.0.jre8'
        }
    }
}

plugins {
    id 'java'
    id 'eclipse'
    id 'idea'
    id 'org.springframework.boot' version '2.1.2.RELEASE'
    id 'io.spring.dependency-management' version '1.0.6.RELEASE'
    id 'nu.studer.jooq' version '3.0.2'
    id 'org.flywaydb.flyway' version '5.1.4'
}

group 'org.test.security'
version '0.0.1-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
    mavenLocal()
    jcenter()
}

dependencyManagement {
    imports {
        mavenBom 'org.springframework.boot:spring-boot-starter-parent:2.1.2.RELEASE'
    }
}

configurations {
    developmentOnly
    runtimeClasspath {
        extendsFrom developmentOnly
    }
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-mail'
    implementation 'org.springframework.boot:spring-boot-starter-security'

    implementation 'org.flywaydb:flyway-core:5.2.4'
    implementation 'org.apache.poi:poi:4.0.1'
    implementation 'org.apache.poi:poi-ooxml:4.0.1'

    implementation 'com.microsoft.sqlserver:mssql-jdbc:7.0.0.jre8'
    implementation 'org.firebirdsql.jdbc:jaybird-jdk17:3.0.5'

    implementation 'org.jooq.pro:jooq:3.11.9'
    implementation 'org.jooq.pro:jooq-meta:3.11.9'
    implementation 'org.jooq.pro:jooq-codegen:3.11.9'

    compileOnly 'org.springframework.boot:spring-boot-configuration-processor'

    jooqRuntime 'com.microsoft.sqlserver:mssql-jdbc:7.0.0.jre8'
    jooqRuntime 'org.firebirdsql.jdbc:jaybird-jdk17:3.0.5'

    developmentOnly 'org.springframework.boot:spring-boot-devtools'

    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

jooq {
    version = '3.11.9'
    edition = 'PRO'
    master(sourceSets.main) {
        jdbc {
            driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"
            url = "jdbc:sqlserver://127.0.0.1:1433;databaseName=MyDatabase"
            user = "sa"
            password = "admin123"
        }
        generator {
            database {
                name = "org.jooq.meta.sqlserver.SQLServerDatabase"
                inputSchema = "dbo"
            }
            generate {
                relations = true
                deprecated = false
                records = true
                immutablePojos = true
                fluentSetters = true
            }
            target {
                packageName = 'org.test.security.database.master'
                directory = 'target/generated-src'
            }
        }
    }
}

flyway {
    url = "jdbc:sqlserver://127.0.0.1:1433;databaseName=MyDatabase"
    user = "sa"
    password = "admin123"
    table = "Schema_History"
}

默认情况下,jOOQ将为所有目录(数据库)和所有模式生成代码。如果要将代码生成限制为仅一个数据库,则需要指定inputCatalog,可能还需要指定inputSchema。可以找到一些细节

换句话说,写

database {
    name = "org.jooq.meta.sqlserver.SQLServerDatabase"
    inputCatalog = "my_database_here"
    inputSchema = "dbo"
}

非常感谢。现在它更有意义了。