Skip to content

Commit 91ee590

Browse files
Remove @Persistent from MongoDB entity scanning
This commit removes `org.springframework.data.annotation.Persistent` from the annotation types used for MongoDB entity scanning to align with Spring Data MongoDB. Fixes gh-25797
1 parent 305bcb1 commit 91ee590

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/mongo/MongoDataConfiguration.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,7 +26,6 @@
2626
import org.springframework.context.ApplicationContext;
2727
import org.springframework.context.annotation.Bean;
2828
import org.springframework.context.annotation.Configuration;
29-
import org.springframework.data.annotation.Persistent;
3029
import org.springframework.data.mapping.model.FieldNamingStrategy;
3130
import org.springframework.data.mongodb.core.convert.MongoCustomConversions;
3231
import org.springframework.data.mongodb.core.mapping.Document;
@@ -37,6 +36,7 @@
3736
*
3837
* @author Madhura Bhave
3938
* @author Artsiom Yudovin
39+
* @author Scott Fredericks
4040
*/
4141
@Configuration(proxyBeanMethods = false)
4242
class MongoDataConfiguration {
@@ -48,7 +48,7 @@ MongoMappingContext mongoMappingContext(ApplicationContext applicationContext, M
4848
PropertyMapper mapper = PropertyMapper.get().alwaysApplyingWhenNonNull();
4949
MongoMappingContext context = new MongoMappingContext();
5050
mapper.from(properties.isAutoIndexCreation()).to(context::setAutoIndexCreation);
51-
context.setInitialEntitySet(new EntityScanner(applicationContext).scan(Document.class, Persistent.class));
51+
context.setInitialEntitySet(new EntityScanner(applicationContext).scan(Document.class));
5252
Class<?> strategyClass = properties.getFieldNamingStrategy();
5353
if (strategyClass != null) {
5454
context.setFieldNamingStrategy((FieldNamingStrategy) BeanUtils.instantiateClass(strategyClass));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright 2012-2021 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.autoconfigure.data.mongo.city;
18+
19+
import java.io.Serializable;
20+
21+
import org.springframework.data.annotation.Persistent;
22+
23+
@Persistent
24+
public class PersistentEntity implements Serializable {
25+
26+
private static final long serialVersionUID = 1L;
27+
28+
}

0 commit comments

Comments
 (0)