如何在从 XML 文件加载配置时提供 jooq 生成器自定义策略的地址?

huangapple 未分类评论44阅读模式
英文:

How to give the address of jooq generators custom strategy, while loading the configuration from xml file?

问题

我正在从文件中加载 jooq 配置,并且我有一个自定义生成器设置,如下所示:

<generator>
  <name>gen.generator.myGenerator</name>
    <strategy>
      <name>gen.generator.myGeneratorStrategy</name>
  </strategy>
.
.
</generator>

我正在从我的原始项目的子项目中加载我的策略。

但问题是,如何引用我的策略?因为我遇到了 java.lang.ClassNotFoundException 的错误。

英文:

I am loading jooq configuration from a file and I have a custom generator setting like this:

<generator>
  <name>gen.generator.myGenerator</name>
    <strategy>
      <name>gen.generator.myGeneratorStrategy</name>
  </strategy>
.
.
</generator>

I am loading my strategy from a sub-project of my original project.

but the question is, how to address my strategy? because I get java.lang.ClassNotFoundException

答案1

得分: 0

您的GeneratorStrategy需要出现在代码生成器的类路径中。这意味着您必须确保将包含策略的子项目添加为您的项目的依赖,或者至少添加到jooq-codegen-maven插件中,例如

<plugin>
    <groupId>org.jooq</groupId>
    <artifactId>jooq-codegen-maven</artifactId>
    <executions>...</executions>
    <dependencies>
        <dependency>
            <groupId>com.example</groupId>
            <artifactId>my-subproject-containing-the-strategy</artifactId>
            <version>${my-subproject-version}</version>
        </dependency>
    </dependencies>
</plugin>
英文:

Your GeneratorStrategy needs to be on the classpath of your code generator. This means you have to make sure you add your sub-project containing the strategy as a dependency to your project, or at least to the jooq-codegen-maven plugin, e.g.

&lt;plugin&gt;
    &lt;groupId&gt;org.jooq&lt;/groupId&gt;
    &lt;artifactId&gt;jooq-codegen-maven&lt;/artifactId&gt;
    &lt;executions&gt;...&lt;/executions&gt;
    &lt;dependencies&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;com.example&lt;/groupId&gt;
            &lt;artifactId&gt;my-subproject-containing-the-strategy&lt;/artifactId&gt;
            &lt;version&gt;${my-subproject-version}&lt;/version&gt;
        &lt;/dependency&gt;
    &lt;/dependencies&gt;
&lt;/plugin&gt;

huangapple
  • 本文由 发表于 2020年4月8日 19:29:09
  • 转载请务必保留本文链接:https://java.coder-hub.com/61099608.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定