我是否需要在Maven依赖项中包括EclipseLink modelgen软件包? [英] Do I need to include EclipseLink modelgen package in my Maven dependencies?

查看:76
本文介绍了我是否需要在Maven依赖项中包括EclipseLink modelgen软件包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Netbeans 7.1编写Maven构建的JSF 2.0 Web应用程序.该服务器是GlassFish 3.1,并且EclipseLink是JPA 2.0提供程序.

当我对项目进行清理和构建"时,为JPA元模型生成的所有源代码都会消失,并且不会再出现.因此,Netbeans看到了成堆的未定义符号.到处都是红点.

奇怪的是,如果我运行项目,则将以某种方式生成元模型,然后最终找到其返回Maven项目使用的generate-sources目录的方式. Web应用程序运行.但是没有运行应用程序就无法生成元模型.有时要花几遍!

通过试验,我发现如果将以下内容作为依赖项,则问题会部分消失.清理并生成仍然会在输出中生成错误,但是就IDE而言,模型是生成的.

    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>org.eclipse.persistence.jpa.modelgen.processor</artifactId>
        <version>2.3.0</version>
    </dependency>

有人可以解释正在发生的事情,也许我应该做什么?

解决方案

我正在使用以下依赖项:

<dependency>
  <groupId>org.eclipse.persistence</groupId>
  <artifactId>org.eclipse.persistence.jpa.modelgen.processor</artifactId>
  <version>2.5.2</version>
  <scope>provided</scope>
</dependency>

清理并构建"后,您会看到在构建时确实构建了元模型,并且这些类实际上包含在target/generated-sources/annotations文件夹中.然后将它们放入jar文件中.可以这么说,您可以将它们的范围设置为已提供",以便在构建时使用它,但不包括在整个分布式软件包中.

I am using Netbeans 7.1 to write a Maven-built JSF 2.0 web application. The server is GlassFish 3.1, and EclipseLink as a JPA 2.0 provider.

When I do a "clean and build" of the project, all the generated sources for the JPA meta-model go away and don't come back. So Netbeans sees piles of undefined symbols. Red dots everywhere.

The odd thing is, if I run the project, the meta-model somehow gets generated then, and eventually finds its way back to the generated-sources directory that the Maven project uses. The web app runs. But there is no way to generate the meta-model without running the application. Sometimes it takes several passes!

By experimenting around I discovered that if I include the following as a dependency, the problem partly goes away. The clean-and-build still generates errors in the output, but the model is generated as far as the IDE is concerned.

    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>org.eclipse.persistence.jpa.modelgen.processor</artifactId>
        <version>2.3.0</version>
    </dependency>

Can someone explain what is going on, and perhaps what I should be doing?

解决方案

I am using the following dependency:

<dependency>
  <groupId>org.eclipse.persistence</groupId>
  <artifactId>org.eclipse.persistence.jpa.modelgen.processor</artifactId>
  <version>2.5.2</version>
  <scope>provided</scope>
</dependency>

After a 'clean and build' you will see that the meta model does get built at build time and the classes are in fact included in the target/generated-sources/annotations folder. These then get put into the jar file. So that being said you can scope these as "provided" so it gets used during build time but not included in the overall distributed package.

这篇关于我是否需要在Maven依赖项中包括EclipseLink modelgen软件包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆