mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Use Neo4jManagedTypes to populate the mapping context
See gh-37574
This commit is contained in:
parent
c6abf888cc
commit
e0a5de01ca
@ -33,6 +33,7 @@ import org.springframework.boot.autoconfigure.transaction.TransactionManagerCust
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.data.neo4j.aot.Neo4jManagedTypes;
|
||||
import org.springframework.data.neo4j.core.DatabaseSelectionProvider;
|
||||
import org.springframework.data.neo4j.core.Neo4jClient;
|
||||
import org.springframework.data.neo4j.core.Neo4jOperations;
|
||||
@ -71,12 +72,18 @@ public class Neo4jDataAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public Neo4jMappingContext neo4jMappingContext(ApplicationContext applicationContext,
|
||||
Neo4jConversions neo4jConversions) throws ClassNotFoundException {
|
||||
Neo4jManagedTypes neo4jManagedTypes(ApplicationContext applicationContext) throws ClassNotFoundException {
|
||||
Set<Class<?>> initialEntityClasses = new EntityScanner(applicationContext).scan(Node.class,
|
||||
RelationshipProperties.class);
|
||||
return Neo4jManagedTypes.fromIterable(initialEntityClasses);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public Neo4jMappingContext neo4jMappingContext(Neo4jManagedTypes managedTypes, Neo4jConversions neo4jConversions) {
|
||||
|
||||
Neo4jMappingContext context = new Neo4jMappingContext(neo4jConversions);
|
||||
context.setInitialEntitySet(initialEntityClasses);
|
||||
context.setManagedTypes(managedTypes);
|
||||
return context;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user