@ Override public Properties getConfiguration ( Environment environment ) { Properties properties = new Properties ( ) ; Path pathPrefix = Paths . get ( environment . getName ( ) ) ; URL url = getClass ( ) . getClassLoader ( ) . getResource ( pathPrefix . toString ( ) ) ; if ( url == null && ! environment . getName ( ) . isEmpty ( ) ) { throw new MissingEnvironmentException ( "Directory doesn't exist: " + environment . getName ( ) ) ; } List < Path > paths = new ArrayList <> ( ) ; for ( Path path : configFilesProvider . getConfigFiles ( ) ) { paths . add ( pathPrefix . resolve ( path ) ) ; } for ( Path path : paths ) { try ( InputStream input = getClass ( ) . getClassLoader ( ) . getResourceAsStream ( path . toString ( ) ) ) { if ( input == null ) { throw new IllegalStateException ( "Unable to load properties from classpath: " + path ) ; } PropertiesProvider provider = propertiesProviderSelector . getProvider ( path . getFileName ( ) . toString ( ) ) ; properties . putAll ( provider . getProperties ( input ) ) ; } catch ( IOException e ) { throw new IllegalStateException ( "Unable to load properties from classpath: " + path , e ) ; } } return properties ; }
Get configuration from classpath . See the class - level javadoc for detail on environment resolution .