How to copy a resource or another in Maven depending on the target environment?

后端 未结 5 1191
有刺的猬
有刺的猬 2020-12-07 15:19

I have to create test war and production war, which will have a different log4j.properties file in the WEB-INF directory. I have these files

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-07 15:20

    • Use Maven profiles (http://maven.apache.org/guides/introduction/introduction-to-profiles.html)
    • Create a "dev" and "prod" profile, selecting an alternate set of resources for each profile. Make Dev active by default.

      
          
              dev
              
                  true
              
              
                  
                      
                          src/main/resources/dev
                      
                  
              
          
          
              prod
              
                  
                      
                          src/main/resources/prod
                      
                  
              
          
      
      
    • Build using the desired profile via: mvn install -Pdev or mvn install -Pprod

提交回复
热议问题