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

前端 未结 4 586
庸人自扰
庸人自扰 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:10

    I think you can create two profiles in your pom.xml:

    
      dev
    
    
      
        prod
        
          test
        
      
    
    

    After that, in your src folder, create two folders named dev/resoruces and test/resources and copy your different resources there. After that, add something like this:

    
      
        ${basedir}/src/main/resources
        false
      
      
        ${basedir}/src/main/${environment}/resources
        true
      
    
    

    The ${basedir} depends on the command line parameter, it can be test or dev. You run the maven command like this: mvn clean package -P test.

提交回复
热议问题