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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency on beans validator #172

Closed
dmoidl opened this issue Feb 1, 2021 · 4 comments
Closed

Dependency on beans validator #172

dmoidl opened this issue Feb 1, 2021 · 4 comments
Milestone

Comments

@dmoidl
Copy link
Contributor

dmoidl commented Feb 1, 2021

Hi @kagkarlsson 馃憢

One more issue I've found when trying to integrate db-scheduler into our project: we're using Spring Boot and so I opted for the db-scheduler-spring-boot-starter dependency (convenient!). I was surprised, however, that by simply adding the dependency caused the application to fail during startup. The error looked like this:

***************************
APPLICATION FAILED TO START
***************************

Description:

The Bean Validation API is on the classpath but no implementation could be found

Action:

Add an implementation, such as Hibernate Validator, to the classpath

containing no clue why that has suddenly become a problem.

I did eventually find out that it is caused by the @Validated annotation on the DbSchedulerProperties class. It turns out that the presence of this annotation makes Spring try to load a bean validator which we simply don't have in the project. This is confusing because there's no mention or indication that the db-scheduler-spring-boot-starter needs a bean validator to work properly.

I think this should be mentioned in the README or somewhere so that people know they need to have a bean validator in the classpath to make things work. On the other hand, what I would appreciate even more would be if the library did not depend on it at all. If I'm not mistaken, it seems to be used only in that one class and just to validate that some properties are @NonNull. In my opinion, that doesn't really justify usage of such a library. For example in our case it would mean bringing the validator dependency (~ 1.2 MB) just for this one use-case.

I'm happy to remove the dependency myself and send a PR if you'd be willing to accept it 馃檪

@kagkarlsson
Copy link
Owner

That seems reasonable yes 馃憤 . Agree @evenh ?

@evenh
Copy link
Contributor

evenh commented Feb 1, 2021

I agree. Let's remove @Validated and the explicit (provided) dependency on hibernate-validator. There is a few other validation mechanisms built-in (e.g. converting durations and parsing booleans) as well as mechanisms built by @kagkarlsson. Should be safe, but has to be mentioned in the release notes.

By the way, a great issue description @dmoidl 馃憦馃徎

@dmoidl
Copy link
Contributor Author

dmoidl commented Feb 2, 2021

Thanks guys. I'll have a look at it shortly and send a PR once I have it ready 馃檪

@kagkarlsson
Copy link
Owner

Released in v9.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants