Reading a YAML file from a Maven dependency

Viewed 361

I have a scenario where I have one api-rest.yml file inside one of the Maven dependencies of my Spring project.
This dependency doesn't have any class in it, only static .md and .yml files.
Is there a way I can read this .yml file?
I've already tried the following approaches:

  1. final ResourceBundle rb = ResourceBundle.getBundle("api-rest.yml");
  2.  final ClassLoader classLoader = this.getClass().getClassLoader();
     final ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(classLoader);
         Resource[] resources = new Resource[0];
         try {
             resources = resolver.getResources("classpath:/**/rest/*.yml");
         } catch (final IOException e) {
             e.printStackTrace();
         }
    
0 Answers
Related