From 08e86741fd11dea6917c2543a5bc4e335b887120 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 17 Feb 2021 17:44:58 +0000 Subject: [PATCH] Don't scan for `@Persistent` types as they may not be meant for Neo4j Closes gh-25069 --- .../autoconfigure/data/neo4j/Neo4jDataAutoConfiguration.java | 5 ++--- .../data/neo4j/Neo4jDataAutoConfigurationTests.java | 4 ++-- .../data/neo4j/Neo4jReactiveDataAutoConfigurationTests.java | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfiguration.java index 965f06e84a..02aa2b92a3 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfiguration.java @@ -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 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 { @ConditionalOnMissingBean public Neo4jMappingContext neo4jMappingContext(ApplicationContext applicationContext, Neo4jConversions neo4jConversions) throws ClassNotFoundException { - Set> initialEntityClasses = new EntityScanner(applicationContext).scan(Node.class, Persistent.class, + Set> initialEntityClasses = new EntityScanner(applicationContext).scan(Node.class, RelationshipProperties.class); Neo4jMappingContext context = new Neo4jMappingContext(neo4jConversions); context.setInitialEntitySet(initialEntityClasses); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfigurationTests.java index 8fd1314d2b..52c42d0d65 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfigurationTests.java @@ -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 { 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(); }); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jReactiveDataAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jReactiveDataAutoConfigurationTests.java index a107a81281..d896ab1a4e 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jReactiveDataAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jReactiveDataAutoConfigurationTests.java @@ -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 { 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(); });