【发布时间】:2017-05-24 16:45:22
【问题描述】:
我有一个单独的 jar,其中包含 persistence.xml。此 jar 已作为依赖项添加到具有实体的 jar 的父 pom 中。我想启用静态编织。 根据EclipseLink documentation,我可以将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
我有什么遗漏吗?
【问题讨论】:
-
最后一个 URL 分隔符 - D:\BRIDGE\BRIDGE-PARTIAL\DB\persistence-config\src\main\resources\META-INF/persistence.xml
-
@Rima:那行不通。无论如何,在错误中,它显示它试图从主项目的资源文件夹中获取 persistence.xml
标签: java jpa eclipselink