Maven Change a value in a file based on profile

后端 未结 1 1378
情歌与酒
情歌与酒 2020-12-08 10:28

I have a properties file called ApplicationResources.properties in my application with a property that changes depending on the environment. Let us say the property is:

1条回答
  •  悲哀的现实
    2020-12-08 11:08

    What I want to do is somehow replace the value of the resources.location in the properties file based on the Maven profile in use. Is this even possible?

    Yes it is. Activate resources filtering and define the value to replace in each profile.

    In your ApplicationResources.properties, declare a token to replace like this:

    resources.location=${your.location}
    

    In your POM, add a tag for the appropriate and set it to true like this:

    
      ...
      
        ...
        
          
            src/main/resources
            true
          
          ...
        
        ...
      
      ...
    
    

    Then, add a element within the element inside each profile:

    
      ...
      
        
          my-profile
          ...
          
            /home/username/resources
          
          ...
        
        ...
      
    
    

    More on filtering of resources here and here.

    0 讨论(0)
提交回复
热议问题