Search code examples
javamavenspring-bootgulp

Maven: Import target folder from another module


I have two modules: BE and FE (means backend and frontend). FE modules builds with gulp and results are placed into target folder. BE modules is written on spring boot. Is there any way to import resources from target folder FE's module to BE module and pack into spring boot jar to make it standalone jar?


Solution

  • By default, Spring Boot serves static content from a directory in the classpath called:

    • /static
    • /public
    • /resources
    • /META-INF/resources

    By default, resources are mapped on /**, but you can tune that with the spring.mvc.static-path-pattern property

    Special case for webjar. Any resources with a path in /webjars/** are served from jar files.

    More info in the documentation Static Content

    So you'll need to change where you store your FE file. Or you can customize your MVC configuration:

    @Configuration
    @EnableWebMvc
    public class WebConfig implements WebMvcConfigurer {
    
        @Override
        public void addResourceHandlers(ResourceHandlerRegistry registry) {
            registry.addResourceHandler("/**")
                .addResourceLocations("/mycustompath", "classpath:/anotherone/")
        }
    }