如何有多種配置:
//First configuration
@Configuration
@EnableNeo4jRepositories(basePackages = "org.neo4j.example.repository.dev")
@EnableTransactionManagement
public class MyConfigurationDev extends Neo4jConfiguration {
@Bean
public Neo4jServer neo4jServer() {
return new RemoteServer("http://localhost:7474");
}
@Bean
public SessionFactory getSessionFactory() {
// with domain entity base package(s)
return new SessionFactory("org.neo4j.example.domain.dev");
}
// needed for session in view in web-applications
@Bean
@Scope(value = "session", proxyMode = ScopedProxyMode.TARGET_CLASS)
public Session getSession() throws Exception {
return super.getSession();
}
}
,另一個
//Second config
@Configuration
@EnableNeo4jRepositories(basePackages = "org.neo4j.example.repository.test")
@EnableTransactionManagement
public class MyConfigurationDev extends Neo4jConfiguration {
@Bean
public Neo4jServer neo4jServer() {
return new RemoteServer("http://localhost:7475");
}
@Bean
public SessionFactory getSessionFactory() {
// with domain entity base package(s)
return new SessionFactory("org.neo4j.example.domain.test");
}
// needed for session in view in web-applications
@Bean
@Scope(value = "session", proxyMode = ScopedProxyMode.TARGET_CLASS)
public Session getSession() throws Exception {
return super.getSession();
}
}
你使用哪個版本? –
我正在使用Spring-data-neo4j 4.0.0.RELEASE和Neo4j 2.3.2。 –