我想使用application.yml和profiles方法来外部化db和其他基础结构依赖项。
我目前在主应用程序中硬编码了neo4j url。
@Configuration
@EnableNeo4jRepositories("com.xxx.repository")
@Import(RepositoryRestMvcConfiguration.class)
@EnableAutoConfiguration
public class Application extends Neo4jConfiguration {
public Application() {
setBasePackage("com.xxx.entity");
}
@Bean(destroyMethod = "shutdown")
public GraphDatabaseService graphDatabaseService() {
return new SpringRestGraphDatabase("http://127.0.0.1:7474/db/data");
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
更新:
@Value("${neo4jurl}")
private String neoUrl;
@Bean(destroyMethod = "shutdown")
public GraphDatabaseService graphDatabaseService() {
return new SpringRestGraphDatabase(neoUrl);
}
的src /主/资源/ application.yml
neo4jurl: http://127.0.0.1:7474/db/data