I am using spring-boot. and want to load resources from directory. following code works fine for filesystem environment. But gives FileNotFoundException when working with Jar,because Spring tries to access a file system path, but it can not access a path in JAR.
@EnableAutoConfiguration
@Configuration
public class Application implements CommandLineRunner {
@Autowired
private MongoDBMigrator migrator;
@Autowired
private ApplicationContext ctx;
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Override
public void run(String... args) throws Exception {
migrator.runScripts(ctx.getResources("classpath:db/*.js"));
}
}
what need to be done to make it work with jar as well