Reading properties file from Maven POM file

前端 未结 3 1113
自闭症患者
自闭症患者 2020-12-01 07:26

I have Maven POM file with some configuration and in the section plugins, I have maven tomcat plugin with some configuration like this:

         


        
3条回答
  •  没有蜡笔的小新
    2020-12-01 08:19

    It is not actually possible to load properties from a file using the instructions in the accepted answer as these properties are not available in the pom file though they can be used for filtering. Minimal counter example:

    In pom.xml:

    
      
        
          org.codehaus.mojo
          properties-maven-plugin
          1.0-alpha-2
          
            
            
              
              validate
              
                read-project-properties
              
              
                
                  dev.properties
                
              
            
          
        
        
          org.apache.maven.plugins
          maven-antrun-plugin
          1.6
          
            
              validate
              
                run
              
              
                
                  Displaying value of properties
                  [foo] ${foo}
                
              
            
          
        
      
    
    

    Having in dev.properties:

    foo=bar
    

    Then runnin the command mvn validate produces output:

     [echo] Displaying value of properties
     [echo] [foo] bar
    

提交回复
热议问题