首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >使用Maven生成Eclipselink 2.5元模型

使用Maven生成Eclipselink 2.5元模型
EN

Stack Overflow用户
提问于 2013-06-30 06:00:36
回答 4查看 18.2K关注 0票数 19

我想知道如何使用Maven和Eclipselink 2.5生成静态元模型。在运行Eclipselink2.4时,通过将以下代码行添加到pom.xml中,它工作得很好。

代码语言:javascript
复制
// Generate meta model for eclipselink 2.4 (does not work for 2.5)
    <plugin>
                    <groupId>org.bsc.maven</groupId>
                    <artifactId>maven-processor-plugin</artifactId>
                    <version>1.3.1</version>
                    <executions>
                        <execution>
                            <id>process</id>
                            <goals>
                                <goal>process</goal>
                            </goals>
                            <phase>generate-sources</phase>
                            <configuration>
                                <compilerArguments>-Aeclipselink.persistencexml=src/main/resources/META-INF/persistence.xml</compilerArguments>
                                <processors>
                                    <processor>org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor</processor>
                                </processors>
                                <outputDirectory>${project.build.directory}/generated-sources/meta-model</outputDirectory>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>

但从2.4开始似乎有一些变化,因为我得到了以下错误:

代码语言:javascript
复制
[INFO] javac option: -proc:only
[INFO] javac option: -Aeclipselink.persistencexml=src/main/resources/META-INF/persistence.xml
[INFO] javac option: -processor
[INFO] javac option: org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor
[INFO] javac option: -s
[INFO] javac option: /home/asdf/target/generated-sources/meta-model
[INFO] diagnostic error: Annotation processor 'org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor' not found
[INFO] diagnostic warning: Annotation processing without compilation requested but no processors were found.
[ERROR] execute error
java.lang.Exception: error during compilation
    at org.bsc.maven.plugin.processor.AbstractAnnotationProcessorMojo.executeWithExceptionsHandled(AbstractAnnotationProcessorMojo.java:183)
    at org.bsc.maven.plugin.processor.AbstractAnnotationProcessorMojo.execute(AbstractAnnotationProcessorMojo.java:96)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)

你们能在外面帮我吗?

B.R

EN

回答 4

Stack Overflow用户

发布于 2014-04-08 14:36:54

为了使配置更简单,我建议您测试:https://github.com/ethlo/eclipselink-maven-plugin。您甚至不需要保留更新的persistence.xml文件。

代码语言:javascript
复制
<plugin>
<groupId>com.ethlo.persistence.tools</groupId>
<artifactId>eclipselink-maven-plugin</artifactId>
<version>[version]</version>
<executions>
    <execution>
        <id>weave</id>
        <phase>process-classes</phase>
        <goals>
            <goal>weave</goal>
        </goals>
    </execution>
    <execution>
        <id>modelgen</id>
        <phase>generate-sources</phase>
        <goals>
            <goal>modelgen</goal>
        </goals>
    </execution>
</executions>
</plugin>

注意:我是这个插件的作者。

票数 4
EN

Stack Overflow用户

发布于 2013-08-21 19:10:40

您可能会收到以下错误:

java.lang.RuntimeException: java.lang.SecurityException: class "org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProperties"'s signer information does not match signer information of other classes in the same package

由于未解决的错误快照,目前必须将版本设置为2.5.0- compilation is broken, modelgen jar is signed in maven repository

票数 0
EN

Stack Overflow用户

发布于 2017-08-30 16:08:44

2017年更新:

这个问题的主要答案现在已经过时了。您现在需要执行以下步骤才能使其正常工作。

1)导入所需的依赖:

代码语言:javascript
复制
<!-- https://mvnrepository.com/artifact/org.eclipse.persistence/org.eclipse.persistence.jpa.modelgen.processor -->
<dependency>
    <groupId>org.eclipse.persistence</groupId>
    <artifactId>org.eclipse.persistence.jpa.modelgen.processor</artifactId>
    <version>2.5.2</version>
    <scope>compile</scope>
</dependency>

2)指定persistence.xml位置(这是EL错误的变通方法。请注意,您的路径可能与本例中指定的路径不同):

代码语言:javascript
复制
<build>
  <pluginManagement>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.5.1</version>
            <executions>
                <execution>
                    <id>default-compile</id>
                    <phase>compile</phase>
                    <goals>
                        <goal>compile</goal>
                    </goals>
                </execution>
                [...]
            </executions>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
                <compilerArgs>
                    <arg>-Aeclipselink.persistencexml=src/main/resources/META-INF/persistence.xml</arg>
                </compilerArgs>
            </configuration>
    </plugins>
    [...]
  </pluginManagement>
  [...]
</build>

3)最后参考以下项目,以便使用Maven的新生命周期映射触发执行:Usage of maven Build Helper Maven Plugin

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17385092

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档