Hello!
I am developing a spring application and the following question arose:
How I can load properties from yml file instead adding via Java?
config.yml located in resources folder.
My snippet:
@Configuration
@RequiredArgsConstructor
public class GraphHopperConfig {
/**
* Bean for GraphHopper
* @return
*/
@Bean
public GraphHopper graphHopper() {
com.graphhopper.GraphHopperConfig graphHopperConfig = new com.graphhopper.GraphHopperConfig();
GraphHopper hopper = new GraphHopperOSM().forServer();
hopper.init(graphHopperConfig);
hopper.importOrLoad();
return hopper;
}
}
When I try to start app GraphHopper not seeing the config.yml file.
Using the config.yml is only possible when you use dropwizard.
1 Like
Thanks for the quick response.
I found this topic - Loading GraphHopperServerConfiguration from a single file
Here it is indicated that you can load the configuration from the config.yml
GraphHopperConfig config = <load config from a file>
GraphHopper graphHopperEngine = new GraphHopper().forMobile();
graphHopperEngine.init(config);
graphHopperEngine.importOrLoad();
Those. there is no way to load the configuration using GraphHopperConfig?
Sure, you can try a yaml parser and load the GraphHopperConfig from there, but there is no inbuilt method for this or something.
1 Like
Thank you so much and have a nice day!
system
Closed
July 22, 2021, 11:25pm
#6
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.