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

前端 未结 5 928
执念已碎
执念已碎 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:57

    I had been looking for an answer to what I think is your question, or at least a very similar question. Maven allows you to specify directories for resources using the maven-resources-plugin. I have a few configuration files in one of my resource directories. I've noticed that by putting copies of those files in the etc/ directory that you mention (which is at the beginning of my CLASSPATH) I can change values in those files for use at run time. I then wanted to have that etc/ directory created with copies of everything from my resource directory by default. The copy-resources goal from the maven-resources-plugin allowed me to do that. This stanza from Examples > Copy Resources on the left sidebar (I'm limited to 2 links in this post) is what did it for me:

    
      ...
      
        
          
            maven-resources-plugin
            2.6
            
              
                copy-resources
                
                validate
                
                  copy-resources
                
                
                  ${basedir}/target/extra-resources
                            
                    
                      src/non-packaged-resources
                      true
                    
                                
                            
              
            
          
        
        ...
      
      ...
    
    

提交回复
热议问题