Spring-Boot Resource Not Found when using executeable Jar

后端 未结 3 1082
情话喂你
情话喂你 2020-12-19 09:21

again I face a strange issue and hope someone here can help.

I have a spring boot backend module, what works in eclipse well and application is executeable when sta

3条回答
  •  感动是毒
    2020-12-19 09:57

    I encountered this limitation too and created this library to overcome the issue: spring-boot-jar-resources

    It basically allows you to register a custom ResourceLoader with Spring Boot that extracts the classpath resources from the JAR as needed, transparently:

    new SpringApplicationBuilder()
            .sources(Application.class)
            .resourceLoader(new JarResourceLoader())
            .run(args);
    

    With that ResourceLoader you can do resource.getFile() on any classpath resource.

提交回复
热议问题