我有一个包含persistence.xml的独立jar。这个jar已作为依赖项添加到具有实体的jar的父pom中。我想启用静态编织。 根据{{3}},我可以将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
我有什么遗失的吗?
答案 0 :(得分:1)
我也像你一样尝试了absolulte路径并且没有用。
我认为外部资源文件不是最好的做法。但您可以使用maven-resources-plugin:2.6:在资源 - 资源阶段将资源复制到&lt; #maven-module&gt; / 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在process-classes阶段运行。因此,persistence.xml位于此阶段的&lt; #maven-module&gt; /target/classes/META-INF/persistence.xml中。
使用相对路径并设置
<persistenceXMLLocation>META-INF/persistence.xml</persistenceXMLLocation>
在staticweave-maven-plugin的配置中。