Mavenプラグインを使用して別のJarからのEntityクラスを強化しようとしてopenjpa-maven-plugin
いますが、残念ながら正しい方法が見つかりませんでした。
jar にパッケージ化されたMyPojo
モジュールのクラスが 1 つあります。MyDomain
my-domain.jar
public class MyPojo {
private Long id;
...
}
私の 2 番目のプロジェクトMyJpa
パッケージングmy-jpa.jar
では、それは module に依存しmy-domain.jar
、Maven は Build Time OpenJPA Enhancer を次のように使用するように構成されています。
<plugin>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-maven-plugin</artifactId>
<configuration>
<includes>**/entity/*.class</includes>
<addDefaultConstructor>true</addDefaultConstructor>
<enforcePropertyRestrictions>true</enforcePropertyRestrictions>
</configuration>
<executions>
<execution>
<id>enhancer</id>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa</artifactId>
<version>2.3.0</version>
</dependency>
</dependencies>
</plugin>
orm.xml
で宣言された XML マッピングを使用していますpersistence.xml
。
...
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<mapping-file>META-INF/orm.xml</mapping-file>
...
そして、次のような orm.xml を使用します。
<entity class="MyPojo" access="FIELD">
<table name="MYPOJO"/>
<attributes>
<id name="id">
<generated-value strategy="AUTO"/>
</id>
</attributes>
</entity>
実行mvn install
すると、次のエラーが発生します。
この構成では実行時の最適化は許可されませんが、次の一覧にある型は、ビルド時またはクラスのロード時に javaagent を使用して拡張されませんでした。
クラスMyPojo
をMyJpa
(プロジェクト MyDomain ではなく) プロジェクトに移動すると、機能します。
MyPojo
私の質問は次のとおりです。ビルド時に外部 Jar からのクラスを拡張できるようにするには、何を構成する必要がありますか?