Is there a way to use maven property in Java class during compilation

前端 未结 4 1010
南方客
南方客 2020-12-04 21:58

I just want to use maven placeholder in my Java class at compile time in order to reduce duplication.

Something like that:

pom.xml



        
4条回答
  •  被撕碎了的回忆
    2020-12-04 22:30

    Even though it's not a very nice solution it is possible with the default maven resource plugin.

    First you need to specify the resource plugin.

    
      
        
        
          
            src/main/java
            true
            ../filtered-sources/java
          
          
            src/main/resources
            true
          
        
      
    
    

    Afterwards you will need to change the 'default' configuration of the compiler plugin.

    
      
          
          target/filtered-sources/java
      
     
    

提交回复
热议问题