0

我正在尝试创建一个 maven 原型,我试图在其中自动生成 java 类中的代码。我遇到了 jcodemodel 来生成 java 类。任何人都请指导我做它,我需要在原型中在哪里使用 jcodemodel 以便在特定文件夹中生成一个具有用户给定名称的类文件?

原型在生成代码时从用户那里获取服务名称、工件 ID 等输入。

4

1 回答 1

0

Maven archetypes can use velocity templates to create code, one simple example beeing to create to correct package definitions. The JBoss Wiki contains a simple example of a template containing conditional logic.

If you already have a generator using codemodel, the generate goal of the archetype plugin contains a goals parameter the execute additional plugins after creation. You could let the archetype create only the directory structure, wrap your generator into a maven plugin and then execute on the newly created project.

于 2012-05-10T11:33:54.337 回答