0

mvn packageは、SpringブートアプリケーションでJPAエンティティを拡張しようとすると、openjpa-maven-plugin:enhanceステージで失敗します。SpringブートでOpenJPAエンティティの静的拡張を実行できません

長いエラーの説明は、それはいくつかの理由の一覧です

enhance failed: MetaDataFactory could not be configured (conf.newMetaDataFactoryInstance() returned null).

no configuration properties were found.

あります:あなたはMETA-INF/persistence.xmlのファイルを持っていることを確認してください

  1. を、それは あなたのクラスパスでご利用いただけます

    • 私は、Javaの設定でspring-data-jpaを使用していて、何
      persistence.xmlはありません。 openjpa:enhance
      なしで可能ですか?
  2. プロパティを使用すると、コンフィギュレーションのために使用されているファイルを確認可能な です。 Antを使用している場合は、タスクのネストされた要素の属性または の属性を参照してください。

    • 私は春のorg.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfigurationのサブクラス内のすべてのOpenJPAのプロパティを指定する - 以下のクラスを参照してください。 これはおそらく私が変更する必要があるものですが、どうですか?プロパティファイルを指定する場所はopenjpa-maven-pluginなので見つけることができますか?
  3. セキュリティポリシーが過度に厳格であれば、あなたのOpenJPAの配布のjarファイルが 壊れている、または場合にも発生する可能性があります。

    • は除外 - 私はそれは、彼らが破損していないという証拠だ、プラス私はこのレベルでどのようなセキュリティポリシーを使用していないよchecksumPolicy=failとOpenJPAの瓶を再度ダウンロード確認しました。

のpom.xml

 <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> 
     </plugin> 

OpenJPAの-達人 - プラグインエラー

[INFO] --- openjpa-maven-plugin:2.4.1:enhance (enhancer) @ project-x --- 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 16.707 s 
[INFO] Finished at: 2016-12-15T09:51:36+00:00 
[INFO] Final Memory: 44M/359M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal org.apache.openjpa:openjpa-maven-plugin:2.4.1:enhance 
(enhancer) on project x: Execution enhancer of goal org.apache.openjpa:openjpa-maven-plugin:2.4.1:enhance 
failed: MetaDataFactory could not be configured (conf.newMetaDataFactoryInstance() 
returned null). This might mean that no configuration properties were found. Ensure that 
you have a META-INF/persistence.xml file, that it is available in your classpath, or that 
the properties file you are using for configuration is available. If you are using Ant, 
please see the <properties> or <propertiesFile> attributes of the task's nested <config> 
element. This can also occur if your OpenJPA distribution jars are corrupt, or if your 
security policy is overly strict. -> [Help 1] 

サブクラスのJpaBaseConfiguration

@Import({ 
     LdapConfig.class, 
     SecurityConfig.class, 
     PropertySpringConfig.class 
}) 
@SpringBootApplication 
@EnableJpaRepositories(basePackages = {"com.adam.x.repository"}) 
@EntityScan(basePackages = {"com.adam.x.entity"}) 
public class MyWebApplication extends JpaBaseConfiguration { 

    public static void main(String[] args) { 
     SpringApplication.run(MyWebApplication.class, args); 
    } 

    protected MyWebApplication(
      DataSource dataSource, 
      JpaProperties properties, 
      ObjectProvider<JtaTransactionManager> jtaTransactionManagerProvider) { 
     super(dataSource, properties, jtaTransactionManagerProvider); 
    } 

    @Override 
    protected AbstractJpaVendorAdapter createJpaVendorAdapter() { 
     OpenJpaVendorAdapter jpaVendorAdapter = new OpenJpaVendorAdapter(); 
     jpaVendorAdapter.setShowSql(true); 
     return jpaVendorAdapter; 

    } 

    @Override 
    protected Map<String, Object> getVendorProperties() { 
     HashMap<String, Object> map = new HashMap<String, Object>(); 
     map.put("openjpa.Log", "DefaultLevel=TRACE, Tool=INFO, SQL=TRACE, Runtime=TRACE"); 
     map.put("openjpa.jdbc.MappingDefaults", "IndexLogicalForeignKeys=false,IndexDiscriminator=false"); 
//  map.put("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true)"); 
     map.put("openjpa.RuntimeUnenhancedClasses", "supported"); 
//  map.put("openjpa.DynamicEnhancementAgent", "true"); 
//  map.put("openjpa.weaving", "false"); 
     return map; 
    } 


} 

答えて

0

この回答は私のためにここで整理しました。

mavenプラグインは動作するにはpersistence.xmlが必要です。これはDRYではありませんが、そこに新しいエンティティBeanをリストすることを忘れないでください。

OpenJPA and Spring-boot configuration