一個教程how to embed Neo4j in a java application建議註冊一個關閉掛鉤,像這樣:在Spring 3中註冊關閉鉤子的正確方法是什麼?
Runtime.getRuntime().addShutdownHook(new Thread() {
// do shutdown work here
});
我想知道最好的地方,把這個代碼 - 其實還是需要運行一次春季開始時的任何代碼。它只是一個registering a bean with an init method的案例,並把代碼放在那裏?
我很想知道這一點,更具體地說,在Spring應用程序中使用嵌入式Neo4j時,其他人是如何註冊關閉鉤子的。
你有這樣的註解配置嗎? – chrisjleu
@Bean public GraphDatabaseService graphDatabaseService(){return new EmbeddedGraphDatabase(storeDir,config); } –
@Bean(destroyMethod =「shutdown」)public GraphDatabaseService graphDatabaseService(){return new EmbeddedGraphDatabase(storeDir,config); } – zebeurton