Questions tagged [spring-mongodb]

Do not use this. Use [spring-data-mongodb] instead.

Do not use this. Use instead.

422 questions
2
votes
0 answers

Java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.lang.String java.io.File.path accessible error in java 17

I am upgrading my application from Spring Boot version 2.7.3 to 3.0.2 and Java version 8 to 17. My build is successful but during server startup I am getting below exception - Caused by:…
2
votes
0 answers

Not able to establish connection between mongodb and Springboot through app.properties file

I want to establish connection with mongodb through app.properties files in Spring boot. Currently, I am establishing connection through Uri variable declared in the class file itself. private static String uri…
Raj
  • 123
  • 1
  • 1
  • 11
2
votes
1 answer

Get rid of spring-boot-starter-data-mongodb dependency on vulnerable Log4J version

Given that Log4J 2.x is suffering from a major remote code execution vulnerability (Check vulnerability), I started taking a look at my project dependencies to see if I use Log4J through e.g. slf4j and luckily I am not. But I found another…
Omar Yasser
  • 135
  • 1
  • 5
2
votes
1 answer

Can't connect Spring boot with MongoDb

I'm trying to make a simple progam with Spring Boot work with MongoDB in Spring Boot 2.3.9 From the startup logs I suspect that something is wrong, it seems like it's initialized twice. This is my console output: 2021-03-08 01:54:43.515 INFO 26609…
2
votes
2 answers

Cannot resolve reference to bean 'mongoTemplate' while setting bean property 'mongoOperations

I'm trying to create a spring boot CRUD App using MongoDB. But I'm unable to connect it to the MongoDB Atlas. When I'm running the program the below exception is shown. I'm trying to connect my application to MongDB Atlas clusters using the…
Thiluxan
  • 177
  • 4
  • 13
2
votes
0 answers

Not able to use @JsonTypeInfo for mongoDb entity in spring-boot 2.1.x

I have existing code that is working fine with spring mongo version 1.9.4.RELEASE. Now migrating it to version 2.2.1.RELEASE, but I'm facing an issue with @JsonTypeInfo. Following is the sample code: BaseInterface.java @JsonTypeInfo(use = Id.NAME,…
Devratna
  • 938
  • 1
  • 7
  • 26
2
votes
1 answer

Spring MongoDB Aggregation DBRef

i have spring mongoDB collection user with data as bellow: [{ "_id": { "$oid": "5fd81fb277b245717d34c25e" }, "userName": "banana", "email": "banana", "userRole": { "$ref": "roles", "$id": { "$oid":…
Tung Vo
  • 2,227
  • 5
  • 27
  • 45
2
votes
1 answer

Spring MongoDB UUID support

I want to use UUID instead of the plain String value for fields annotated with @Id, for example: @Data // Lombok public class Role { @Id private UUID id; @Size(max = 18) private String name; } However, inserting such object leads…
Yves Calaci
  • 1,019
  • 1
  • 11
  • 37
2
votes
0 answers

Spring Data Mongo: Persisting Maps with non-simple Keys

I have a model data class SomeComplexObject(val name: String, val value: T) @Document("model") data class SomeModel(val id: String? = null, val map: Map, Int>) Which I save to Mongo via the save method…
Eduardo
  • 6,900
  • 17
  • 77
  • 121
2
votes
1 answer

How to Convert MongoDB Query to Spring Data Query

I'm trying to convert the following Mongo query for use with Spring data. db.product.aggregate([ {$unwind: '$barcodes'}, {$project: { _id: 0, productId: '$_id', productTitle: '$title', productVariation: '$variation', barcode:…
Kylep5587
  • 87
  • 6
2
votes
1 answer

Mongo Java Driver version mismatch with spring framework

I have springboot (2.0.4) application with Mongo Java driver version 3.11.2. When upgrading the application for mongo java driver to version 4.1.0 to use IAM authentication feature of new mongo java driver, the changes are breaking with overall…
2
votes
1 answer

how to solve No qualifying bean of type 'com.example.test.repository.ConfigRepository' available: expected at least 1 bean which qualifies autowire

Following is my directory structure com.example com.example.common com.example.test com.example.test.repository my main spring boot class is as follow package com.example.test; @Import({ AutoConfig.class }) @SpringBootApplication public class…
Roshan
  • 77
  • 9
2
votes
1 answer

ns does not exist, com.mongodb.MongoCommandException

Using mongock to perform the data migration but end up with below error. Gradle plugins { id 'java' } group 'fete.bird' version '0.0.1-SNAPSHOT' repositories { mavenCentral() } ext { set('mongockVersion', "4.1.14") } dependencies { …
San Jaisy
  • 15,327
  • 34
  • 171
  • 290
2
votes
0 answers

MongoTemplate AnnotationBasedPersistentProperty.isWritable concurrency problem

exception stack java.lang.IllegalStateException: Expected lazy evaluation to yield a non-null value but got null! at org.springframework.data.util.Lazy.get(Lazy.java:66) at…
2
votes
0 answers

SpringBoot Security & MongoRepository how to fetch user by username and password

I have Spring boot app that uses mongo as db. I am using spring-security to secure my endpoints: org.springframework.boot spring-boot-starter-security
user2739823
  • 397
  • 1
  • 7
  • 24