Skip to content
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

Allow manually setting of MongoDB instead of using Autowired details #694

Closed
ClaudioConsolmagno opened this issue Aug 3, 2018 · 5 comments

Comments

Projects
None yet
3 participants
@ClaudioConsolmagno
Copy link

commented Aug 3, 2018

Currently JaversMongoAutoConfiguration.java forces you to use the autowired MongoClient (and MongoProperties). This is fine if you want to have javers auditing in the same host:DB as your primary mongoDB.

We have a use case where we want to keep the (javers) auditing DB and primary MongoDB separate and for that we want to be able to pass in mongo credentials from the properties file (e.g. with javers.uri) that will cause the autoconfig class to create a MongoClient instead of using the autowired instance.

What are the thoughts on this? Would be happy to submit a pull-request.

@bartoszwalacik

This comment has been minimized.

Copy link
Member

commented Aug 3, 2018

Hi. Looks like a good idea, we will be happy to merge your PR

@shirishpandharikar

This comment has been minimized.

Copy link
Contributor

commented Jun 3, 2019

@ClaudioConsolmagno @bartoszwalacik Any thoughts on this? I was looking into this and it doesn't seem to be a straightforward fix. Essentially we would have to define all configuration properties for MongoDB in JaversMongoProperties and inject MongoDatabase instead of a MongoClient. We also need a configuration property, let's say javers-properties-override [couldn't find a better name] which if set to true tells Javers to create its own MongoClient and obtain a MongoDatabase instance. If set to false, it will fall back to using the spring-boot-starter-data-mongodb configured instance.

@bartoszwalacik

This comment has been minimized.

Copy link
Member

commented Jun 4, 2019

Indeed, some props have to be added, for example:

javers:
    mongodb:
        database: my-db
        host: "localhost"
        ....

Maybe it's enough to check if any of javers.mongodb.* props is present instead of using javers-properties-override?

shirishpandharikar pushed a commit to shirishpandharikar/javers that referenced this issue Jun 4, 2019

Shirish Pandharikar
Fix for javers#694
Added README.md
@shirishpandharikar

This comment has been minimized.

Copy link
Contributor

commented Jun 4, 2019

@bartoszwalacik Have a look at the PR and let me know how it looks.

bartoszwalacik added a commit that referenced this issue Jun 12, 2019

bartoszwalacik added a commit that referenced this issue Jun 13, 2019

bartoszwalacik added a commit that referenced this issue Jun 13, 2019

@bartoszwalacik

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.