Browse Source

Don't scan for `@Persistent` types as they may not be meant for Neo4j

Closes gh-25069
pull/25507/head
Andy Wilkinson 5 years ago
parent
commit
08e86741fd
  1. 5
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfiguration.java
  2. 4
      spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfigurationTests.java
  3. 4
      spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jReactiveDataAutoConfigurationTests.java

5
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfiguration.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -35,7 +35,6 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties @@ -35,7 +35,6 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.annotation.Persistent;
import org.springframework.data.neo4j.core.DatabaseSelectionProvider;
import org.springframework.data.neo4j.core.Neo4jClient;
import org.springframework.data.neo4j.core.Neo4jOperations;
@ -78,7 +77,7 @@ public class Neo4jDataAutoConfiguration { @@ -78,7 +77,7 @@ public class Neo4jDataAutoConfiguration {
@ConditionalOnMissingBean
public Neo4jMappingContext neo4jMappingContext(ApplicationContext applicationContext,
Neo4jConversions neo4jConversions) throws ClassNotFoundException {
Set<Class<?>> initialEntityClasses = new EntityScanner(applicationContext).scan(Node.class, Persistent.class,
Set<Class<?>> initialEntityClasses = new EntityScanner(applicationContext).scan(Node.class,
RelationshipProperties.class);
Neo4jMappingContext context = new Neo4jMappingContext(neo4jConversions);
context.setInitialEntitySet(initialEntityClasses);

4
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfigurationTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -148,7 +148,7 @@ class Neo4jDataAutoConfigurationTests { @@ -148,7 +148,7 @@ class Neo4jDataAutoConfigurationTests {
this.contextRunner.withUserConfiguration(EntityScanConfig.class).run((context) -> {
Neo4jMappingContext mappingContext = context.getBean(Neo4jMappingContext.class);
assertThat(mappingContext.hasPersistentEntityFor(TestNode.class)).isTrue();
assertThat(mappingContext.hasPersistentEntityFor(TestPersistent.class)).isTrue();
assertThat(mappingContext.hasPersistentEntityFor(TestPersistent.class)).isFalse();
assertThat(mappingContext.hasPersistentEntityFor(TestRelationshipProperties.class)).isTrue();
assertThat(mappingContext.hasPersistentEntityFor(TestNonAnnotated.class)).isFalse();
});

4
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jReactiveDataAutoConfigurationTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -132,7 +132,7 @@ class Neo4jReactiveDataAutoConfigurationTests { @@ -132,7 +132,7 @@ class Neo4jReactiveDataAutoConfigurationTests {
this.contextRunner.withUserConfiguration(EntityScanConfig.class).run((context) -> {
Neo4jMappingContext mappingContext = context.getBean(Neo4jMappingContext.class);
assertThat(mappingContext.hasPersistentEntityFor(TestNode.class)).isTrue();
assertThat(mappingContext.hasPersistentEntityFor(TestPersistent.class)).isTrue();
assertThat(mappingContext.hasPersistentEntityFor(TestPersistent.class)).isFalse();
assertThat(mappingContext.hasPersistentEntityFor(TestRelationshipProperties.class)).isTrue();
assertThat(mappingContext.hasPersistentEntityFor(TestNonAnnotated.class)).isFalse();
});

Loading…
Cancel
Save