Serving Static resources from file system | Spring Boot Web

前端 未结 4 636
忘了有多久
忘了有多久 2020-12-14 01:58

Using a Spring Boot web application I trying to serve my static resource from a file system folder outside my project.

Folder structure looks like:-

         


        
4条回答
  •  星月不相逢
    2020-12-14 02:58

    Spring Boot Maven Plugin can add extra directories to the classpath. In your case you could include that in your pom.

    
        org.springframework.boot
        spring-boot-maven-plugin
        ${spring.boot.version}
        
            
                ${project.build.directory}/../ext-resources
            
    
            ...
        
    
    

    So that way you don't need inlcude any hard-code in your classes. Simply start your webapp with

    mvn spring-boot:run
    

提交回复
热议问题