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
Labels
contribution wanted this feature is wanted but won't be implemented by core team due to limited resources fixed good first issue

Comments

@ClaudioConsolmagno
Copy link

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
Copy link
Member

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

@bartoszwalacik bartoszwalacik added contribution wanted this feature is wanted but won't be implemented by core team due to limited resources and removed enhancement labels Sep 15, 2018
@shirishpandharikar
Copy link
Contributor

@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
Copy link
Member

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
Added README.md
@shirishpandharikar
Copy link
Contributor

@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
Copy link
Member

fixed in 5.6.0
see https://javers.org/documentation/spring-boot-integration/#starter-repository-configuration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution wanted this feature is wanted but won't be implemented by core team due to limited resources fixed good first issue
Projects
None yet
Development

No branches or pull requests

3 participants