spring boot 打包分离依赖及配置文件

使用maven命令打包,不同的IDE可以一样的操作

在pom文件中,设置两个属性

	
		lib/
		resource/
	

设置build节点。这样在pom文件目录执行mvn clean package命令,就能在target文件夹输出打包结果了:依赖的jar会输出到output.dependence.file.path指定的文件夹,配置文件输出到output.resource.file.path 指定的文件夹


   configServer
   
      
      
         org.apache.maven.plugins
         maven-jar-plugin
         
            
            
               *.properties
               *.yml
               */*.properties
               */*.yml
            
            
               
                  true
                  
                  
                  ${output.dependence.file.path}
                  
                  false
                  
                  com.SprCld.configServer.ConfigServerApplication
               
               
                  
                  
                  ./${output.resource.file.path}
               
            
            ${project.build.directory}
         
      

      
      
         org.apache.maven.plugins
         maven-dependency-plugin
         
            
               copy-dependencies
               package
               
                  copy-dependencies
               
               
                  ${project.build.directory}/${output.dependence.file.path}
               
            
         
      

      
      
         maven-resources-plugin
         
            
            
               copy-resources
               package
               
                  copy-resources
               
               
                  
                     
                        src/main/resources
                        
                           *.properties
                           *.yml
                           */*.properties
                           */*.properties
                        
                     
                  
                  ${project.build.directory}/${output.resource.file.path}
               
            
         
      

      
      
      
         org.springframework.boot
         spring-boot-maven-plugin
         
            
            
               
                  null
                  null
               
            
            ${project.build.directory}
         
         
            
               
                  repackage
               
               
                  
                  
                  
               
            
         
      
      
      
         org.apache.maven.plugins
         maven-surefire-plugin
         
            true
         
      

   

 

你可能感兴趣的:(Spring,Boot)