jOOQ codegen 由于“无效内容”“visibilityModifier”和“includeExcludePackageRoutines”而失败

问题描述 投票:0回答:2

我有一个

postgres:13.5-alpine
数据库正在运行,并像这样设置 jOOQ:

版本

plugin_jooq=7.1.1
lib_jooq=3.16.6

梯度

plugins {
    id 'nu.studer.jooq' version "${plugin_jooq}"
}

dependencies {
    api "org.postgresql:postgresql"

    implementation "org.jooq:jooq:${lib_jooq}"
    implementation "org.jooq:jooq-meta:${lib_jooq}"
    implementation "org.jooq:jooq-codegen:${lib_jooq}"
}

jooq {
    version = "${lib_jooq}"
    edition = nu.studer.gradle.jooq.JooqEdition.OSS

    configurations {
        mydb {
            generateSchemaSourceOnCompilation = true

            generationTool {
                logging = org.jooq.meta.jaxb.Logging.WARN
                jdbc {
                    driver = 'org.postgresql.Driver'
                    url = 'jdbc:postgresql://localhost:5432/mydb'
                    user = '<username>'
                    password = '<password>'
                    properties {
                        property {
                            key = 'PAGE_SIZE'
                            value = 2048
                        }
                    }
                }
                generator {
                    name = 'org.jooq.codegen.DefaultGenerator'
                    database {
                        name = 'org.jooq.meta.postgres.PostgresDatabase'
                        inputSchema = 'public'
                        includes = '.*'
                        excludes = ''
                    }
                    target {
                        directory = 'build/generated/sources/'
                        packageName = 'my.app.jooq'
                    }
                }
            }
        }
    }
}

build.dependsOn generateMydbJooq

当我运行 codegen 时,我得到

org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 927; cvc-complex-type.2.4.a:
Invalid content was found starting with element
'{"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":includeExcludePackageRoutines}'.

One of '{
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":properties, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":regexFlags, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":includeTables, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":includeEmbeddables, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":includeRoutines, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":includeTriggerRoutines, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":includePackages, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":includePackageRoutines, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":includePackageUDTs, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":includePackageConstants, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":includeUDTs, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":includeDomains, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":includeSequences, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":includeIndexes, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":includePrimaryKeys, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":includeUniqueKeys, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":includeForeignKeys, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":includeCheckConstraints, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":includeSystemIndexes, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":includeSystemCheckConstraints, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":includeInvisibleColumns, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":recordVersionFields, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":recordTimestampFields, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":syntheticObjects, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":syntheticIdentities, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":syntheticPrimaryKeys, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":overridePrimaryKeys, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":dateAsTimestamp, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":ignoreProcedureReturnValues, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":unsignedTypes, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":integerDisplayWidths, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":inputCatalog, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":outputCatalog, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":outputCatalogToDefault, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":inputSchema, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":outputSchema, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":outputSchemaToDefault, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":catalogs, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":schemata, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":schemaVersionProvider, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":catalogVersionProvider, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":orderProvider, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":embeddables, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":embeddablePrimaryKeys, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":embeddableUniqueKeys, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":embeddableDomains, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":customTypes, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":enumTypes, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":forcedTypes, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":forceIntegerTypesOnZeroScaleDecimals, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":tableValuedFunctions, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":logSlowQueriesAfterSeconds, 
"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":logSlowResultsAfterSeconds
}' is expected.
org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 3351; cvc-complex-type.2.4.a: Invalid content was found starting with element
'{"http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd":visibilityModifier}'.

One of '{...}' is expected.

我该如何解决这个问题?

更新

尝试应用@LukasEder 的建议。添加了构建脚本,但错误仍然存在。启动一些依赖关系树,这些是唯一提到 jooq 的依赖关系:

+--- project :my-app
|    +--- org.jooq:jooq:3.16.6 -> 3.14.15
|    |    +--- org.reactivestreams:reactive-streams:1.0.2 -> 1.0.3
|    |    \--- javax.xml.bind:jaxb-api:2.3.1
|    |         \--- javax.activation:javax.activation-api:1.2.0

|    +--- org.jooq:jooq-meta:3.16.6 -> 3.14.15
|    |    \--- org.jooq:jooq:3.14.15 (*)
|    \--- org.jooq:jooq-codegen:3.16.6 -> 3.14.15
|         +--- org.jooq:jooq:3.14.15 (*)
|         \--- org.jooq:jooq-meta:3.14.15 (*)

更新

降级到 3.14.15 并没有解决这个问题。

java postgresql jooq jooq-codegen
2个回答
1
投票

您正在使用的第三方代码生成插件似乎连接到配置对象的旧 XSD 版本。这可能有多种原因,不确定为什么会遇到这种情况,但根据此处的文档: https://github.com/etiennestuder/gradle-jooq-plugin#enforcing-the-jooq-configuration-xml-schema-version

您可以像这样强制执行 XSD 版本:

buildscript {
    configurations['classpath'].resolutionStrategy.eachDependency {
        if (requested.group == 'org.jooq') {
            useVersion '3.16.6'
        }
    }
}

0
投票

我认为你需要更新:

generateSchemaSourceOnCompilation = false
© www.soinside.com 2019 - 2024. All rights reserved.