How to instruct Maven to ignore my main/resources/persistence.xml in favor of test/…?

前端 未结 4 581
庸人自扰
庸人自扰 2021-02-07 08:28

I have two persistence.xml files, for the sake of testing:

  • src/main/resources/META-INF/persistence.xml
  • src/test/resources/
4条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-07 09:33

    I have been testing these and other similar solutions without involving the pom.xml... In my opinion, the best way to solve this issue is to have two application-context.xml (one only to be used in test classes) and to add a custom persistence unit manager bean in the test's application-context.xml. Like this example:

    
      
         classpath*:META-INF/test.persistence.xml
      
      
    
    

    This solution runs. :)

提交回复
热议问题