JOOQ Codegen因“无效内容”而失败。 `visibilityModifier`和`includeexcludePackageroutines''

发布于 2025-02-07 10:10:40 字数 6747 浏览 3 评论 0 原文

我有一个 postgres:13.5-alpine 数据库运行并设置jooq so:

wersions

plugin_jooq=7.1.1
lib_jooq=3.16.6

gradle

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的建议。添加了buildScript,但错误仍然存​​在。旋转一些依赖树,这些是提及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 (*)

update

降级到3.14.15无法解决。

I have a postgres:13.5-alpine database running and set up jOOQ like so:

versions

plugin_jooq=7.1.1
lib_jooq=3.16.6

gradle

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

when I run codegen, I get

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.

How do I resolve this?

UPDATE

Trying to apply @LukasEder's suggestion. Added the buildscript but error persists. Spun up some dependency tree, and these are the only dependencies mentioning 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 (*)

UPDATE

Downgrade to 3.14.15 did not resolve this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

短叹 2025-02-14 10:10:40

您使用的第三方代码生成插件似乎已连接到用于配置对象的旧XSD版本。这可能有多种原因,不确定您为什么要遇到这个问题,但是根据此处的文档:

您可以执行这样的XSD版本:

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

The third party code generation plugin you're using seems to be wired towards an older XSD version for your configuration objects. This can have various reasons, not sure why you're running into this, but as per the documentation here:
https://github.com/etiennestuder/gradle-jooq-plugin#enforcing-the-jooq-configuration-xml-schema-version

You can enforce an XSD version like this:

buildscript {
    configurations['classpath'].resolutionStrategy.eachDependency {
        if (requested.group == 'org.jooq') {
            useVersion '3.16.6'
        }
    }
}
凉城已无爱 2025-02-14 10:10:40

我认为您需要更新:

generateSchemaSourceOnCompilation = false

I think you need to update:

generateSchemaSourceOnCompilation = false
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文