Where should I put application configuration files for a Maven project?

前端 未结 5 907
执念已碎
执念已碎 2020-12-30 10:38

I\'m using the Maven Application Assembler plugin to generate stand-alone executables from my Java project. The application reads in configuration files, including Spring fi

5条回答
  •  孤城傲影
    2020-12-30 10:52

    You can also use resource filtering: http://maven.apache.org/guides/getting-started/index.html#How_do_I_filter_resource_files

    turn on filtering:

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

    make a file under src/main/resources like: application.properties

    application.properties

    configprop.1=${param1}
    configprop.2=${param2}
    

    Then setup a profile and set some properties perhaps in a settings.xml that sets different properties depending on if this is a dev or production build. see: http://maven.apache.org/guides/introduction/introduction-to-profiles.html

    I have different properties set depending on if this is the build server, dev or a production deployment

    mvn -Denv=dev || mvn -Denv=dev-build || mvn -Denv=production

    The maven link has a pretty good description.

提交回复
热议问题