[英]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 命令是什么?
以下是我在執行插件時得到的錯誤:
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 文件。
我使用的 mvn 命令是:
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
有什么我想念的嗎?
我也像你一樣用絕對路徑試過了,但沒有用。
我認為外部資源文件不是最佳做法。 但是你可以使用 maven-resources-plugin:2.6:resources 在 process-resources 階段將資源復制到 <#maven-module>/target/classes。
<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。
使用相對路徑並設置
<persistenceXMLLocation>META-INF/persistence.xml</persistenceXMLLocation>
在 staticweave-maven-plugin 的配置中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.