-
Notifications
You must be signed in to change notification settings - Fork 40.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'spring.data.mongodb.auto-index-creation=true' not working #28478
Comments
Did you always have an Line 50 in 3467750
If the problem occurs without an |
I only created the AbstractMongoClientConfiguration to try the override. |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue. |
Hi, I don't want to open a new issue, but I encountered the same problem and tested it with Spring Boot 2.5.3 and 2.5.5 like the opener. If I overwrite I always have a |
Yes, it is. Please see my comment above that hopefully explains why that's the case. |
The behavior is still the same in Spring Boot 2.6.0. spring.data.mongodb.auto-index-creation=true' has no effect. I am not using AbstractMongoClientConfiguration right now and nothing else is configured. |
@NicoHeller No changes have been made so the same behaviour is to be expected. Thus far, as far as we know, everyone who has had this problem has defined their own |
Sorry. I have simply forgotten the @document annotation above the "Entity", if that is there everything works out of the box with spring.data.mongodb.auto-index-creation=true |
Thanks for letting us know. Good to hear you've got things working. |
More precisely, also for other people, a POJO without |
Just to add back to this as the OP. |
Hi, just to contribute I was with my configs all set, but it was not working, then a did the following change in my Before (not creating indexes) @Bean(name = "QualifierName")
public MongoTemplate mongoTemplate() {
ConnectionString connectionString = new ConnectionString(this.uri);
MongoDatabaseFactory clientDatabaseFactory = new SimpleMongoClientDatabaseFactory(connectionString);
return new MongoTemplate(clientDatabaseFactory);
} After (creating indexes) - just added @Bean(name = "QualifierName")
public MongoTemplate mongoTemplate(MappingMongoConverter converter) {
ConnectionString connectionString = new ConnectionString(this.uri);
MongoDatabaseFactory clientDatabaseFactory = new SimpleMongoClientDatabaseFactory(connectionString);
return new MongoTemplate(clientDatabaseFactory, converter);
} |
In one of my project I am also facing similar issue and AbstractMongoClientConfiguration class does not contain the method autoIndexCreation. |
I've added as per the documentation the following line to my application.properties:
spring.data.mongodb.auto-index-creation=true
However there is still no index created in my model-class that is annotated with @document and the field with @indexed.
If I overwrite autoIndexCreation in Java via:
the index is created. So this method works, but the application.properties entry doesn't work.
Using Spring Boot 2.5.5
The text was updated successfully, but these errors were encountered: