Search code examples
javamavenhibernate-validator

partion same dependency name with muiltiple versions in the same project


I have a Spring module having: 1) depedency org.hibernate-validator 6... 2) transitive depedency org.hibernate-validator 5... 3) uber transitive depedency hardFileCoded in fat jar(gwt-user) of vaadin dependency with org.hibernate-validator <6

They seem uncompatible to interchange.

The problem is - they do not conflict and raise ex. But in compiletime(it follows bad artifact till successful remake) they mess randomly(?). And wrong version(?) is used for retriving validation message error text. Resulting in bad print because versions <=5 does not have javax.validation.constraints.NotBlank.message:

Object: ***, error: {javax.validation.constraints.NotBlank.message}

instead of correct:

Object: ***, error: must not be blank

I can't really remove something etc. Need somehow to distinguish them and use appropriate versions in places. First of all limit that fat jar validator to never go out of vaadin =)

Thanks a lot in advance for any directions to dig.


Solution

    • As always you should look for a normal healthy dependency
    • where you can <exclude> (maven) some transitives and include them explicitly with the right version
    • also check this dependency is really needed
    • in rare extra cases see classloaders, so you can load same classes of different versions for a different consumers

    In my concrete case found that fat jar unused and free to delete =) Thanks for recommendations.