如何使用Maven在带有远程persistence.xml的eclipseLink中启用静态编织? [英] How to enable static weaving in eclipseLink with remote persistence.xml using Maven?
问题描述
我有一个单独的jar,其中包含persistence.xml.此jar已作为依赖项添加到具有实体的jar的父pom中.我想启用静态编织. 根据 EclipseLink文档,我可以指定persistenceXMLLocation作为配置.但是,该位置应该是我的persistence.xml的绝对文件路径,还是它在存储库中的路径.另外,如何在启用编织的情况下构建实体jar?执行该插件的maven命令是什么?
I have a separate jar which contains the persistence.xml. This jar has been added as a dependency in the parent pom of the jar which has the entities. I want to enable static weaving. According to EclipseLink documentation, I can specify the persistenceXMLLocation as a configuration. However, should this location be an absolute file path of my persistence.xml or its path in a repository. Also how can I build my entities jar with weaving enabled? What would be the maven command to execute this plugin?
以下是我在执行插件时收到的错误:
Following is the error I get when the plugin is executed:
Failed to execute goal de.empulse.eclipselink:staticweave-maven-plugin:1.0.0:weave (default-cli) on project BRBASE-techl-entities: Execution default-cli of goal de.empulse.eclipselink:staticweave-maven-plugin:1.0.0:weave failed:
[ERROR] Exception Description: An exception was thrown while trying to load persistence unit at url: file:/D:/BRIDGE/BRIDGE-PARTIAL/BRBASE_Branch_selective_fetch/src/core/techl/entities/target/classes/
[ERROR] Internal Exception: Exception [EclipseLink-30004] (Eclipse Persistence Services - 2.5.1.v20130824-981335c): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
[ERROR] Exception Description: An exception was thrown while processing persistence.xml from URL: file:/D:/BRIDGE/BRIDGE-PARTIAL/BRBASE_Branch_selective_fetch/src/core/techl/entities/target/classes/
[ERROR] Internal Exception: java.net.MalformedURLException: NullPointerException
这里,它在实体项目的类路径中寻找persistence.xml文件.
Here, its looking for the persistence.xml file in the entities project's classpath.
我正在使用的mvn命令是:
The mvn command I am using is :
de.empulse.eclipselink:staticweave-maven-plugin:weave
插件为:
<plugin>
<groupId>de.empulse.eclipselink</groupId>
<artifactId>staticweave-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>weave</goal>
</goals>
<configuration>
<logLevel>FINE</logLevel>
<persistenceXMLLocation>D:\BRIDGE\BRIDGE-PARTIAL\DB\persistence-config\src\main\resources\META-INF\persistence.xml</persistenceXMLLocation>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa</artifactId>
<version>2.5.1-RC1</version>
</dependency>
<dependency>
<groupId>com.mindtree.bridge.platform.db</groupId>
<artifactId>BRDB-persistence-config</artifactId>
<version>${db.version}</version>
</dependency>
</dependencies>
</plugin>
使用的EclipseLink版本:2.5.1-RC1
EclipseLink version used : 2.5.1-RC1
有什么我想念的吗?
推荐答案
我也像您一样使用绝对路径尝试了它,但它不起作用.
我认为外部资源文件不是最佳实践.但是您可以使用maven-resources-plugin:2.6:resources做到这一点,以在process-resources阶段将资源复制到<#maven-module>/target/classs.
I also tried it with absolulte path like you and it is not worked.
I think the external resource files are not the best practise. But you can do it with maven-resources-plugin:2.6:resources to copy resources to <#maven-module>/target/classes in the process-resources phase.
<resources>
<!-- ... -->
<resource>
<directory>D:/BRIDGE/BRIDGE-PARTIAL/DB/persistence-config/src/main/resources</directory>
<includes>
<include>META-INF/persistence.xml</include>
</includes>
</resource>
</resources>
而且staticweave-maven-plugin:1.0.0:weave在流程类阶段运行.因此,在此阶段,persistence.xml位于<#maven-module>/target/classes/META-INF/persistence.xml中.
使用相对路径并设置
And staticweave-maven-plugin:1.0.0:weave runs in the process-classes phase. So the persistence.xml is located in <#maven-module>/target/classes/META-INF/persistence.xml in this phase.
Use relative path and set the
<persistenceXMLLocation>META-INF/persistence.xml</persistenceXMLLocation>
在staticweave-maven-plugin的配置中.
in the configuration of staticweave-maven-plugin.
这篇关于如何使用Maven在带有远程persistence.xml的eclipseLink中启用静态编织?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!