Maven:使用spring-boot-maven-plugin时如何添加资源和类文件

在使用spring-boot-maven-plugin对当前工程打JAR包时,经常需要将一些非默认路径下的资源和类文件也一同添加到JAR包中,则可以在pom.xml中配置如下内容


    

        
            org.springframework.boot
            spring-boot-maven-plugin
            2.0.0.RELEASE
            
                -Dfile.encoding=UTF-8
                com.test.TestApplication
                ZIP

            

            
                
                    
                        repackage
                    

                

            

        

    
    
        
            false
            target/test-classes
            
                **/*.class
            

        

    

 本例中是将target/test-classes下的类文件也一同添加到最终JAR包中。另外,中包含的在文档中也说可以用于添加资源和类文件到JAR中,但试过后不起作用,不知道是不是哪里配置的不对。

 

参考文档

Available Plugins
Introduction to Plugin Prefix Resolution
Apache Maven Resources Plugin
Apache Maven Compiler Plugin
Spring Boot Maven Plugin

 

你可能感兴趣的:(Maven,Java)