creating bean with name 'mongoRC' defined in ru.majordomo.hms.service.config.MongoConfig: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.mongodb.MongoClient]: Factory method 'mongoRC' threw exception; nested exception is java.lang.IllegalArgumentException: The connection string is invalid. Connection strings must start with either 'mongodb://' or 'mongodb+srv://",
——
datasource:
mongodbRc:
uri: mongodb://dev.internal:27017/database
database: database
^ is 100% correct
——
@Value("${datasource.mongodbRc.uri}")
private String mongodbRCUri;
@Bean("mongoRC")
public MongoClient mongoRC() {
return new MongoClient(new MongoClientURI(mongodbRCUri));
}
eh? What's the problem
verify if the YAML formatting is correct
Please use del.dog or hastebin.com to share long snippets of code. It helps preserve formatting and can give you suntax highlighting
I didn't know about del.dog and hastebin.com won't save anything for me Sorry
That's fine, any code pasting website will do.
Which spring boot and spring-data-mongo are you using? I tried couple of versions I work with, in both of them MongoClient is an *interface*, not a concrete class
Basically, configuration looks correct. but the way how you create client - does not. at a glance
It wasn't me who wrote, so I'll look into this then now, thanks! Maybe I'll rewrite if it's simple or just drop the idea of using mongoOperations
Hello Manav! pastebin didn't worked for me, I got two warnings when ttried to share code here. Is pastebin somehow special ? It's not explicitly mentioned in rules that pastebin is not allowed here
MongoOperations depends on MongoClient. Basically every interaction with mongo needs a properly configured MongoClient ))) And your failure shows that it's misconfigured. So it's not about mongoOperations. I suggest to give a glance at the documentation: https://docs.spring.io/spring-data/mongodb/docs/current/reference/html/#mongodb-connectors
You've got warnings for that? Lemme see
Any pasting service should work. Did you mention someone? It was probably a mistake. Lemme ask other admins
What did you send exactly?
Hello! Hard to tell exactly, as the full message was automatically deleted. But I can try sharing same link again. Should I?
I added qualifier instead of getting certain bean with ctx and it works now
Can you please share how you solved it (if it's non-nda of course)?
https://del.dog/ungimutoci
Обсуждают сегодня