I wanted to create a Web-App that would use neo4j with Spring Data. I’m using Maven to handle the dependencies and building, and I’m having trouble doing this because of dependencies of spring-data-neo4j.
When I include spring-data-neo4j, it includes javax.validation, but when this is included, I have issues using <mvc:annotation-driven /> to pick up my @Controller and @RequestMapping annotations, which causes this issue:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.validation.beanvalidation.LocalValidatorFactoryBean#0': Invocation of init method failed; nested exception is javax.validation.ValidationException: Unable to find a default provider
If I exclude javax.validation as a dependency from spring-data-neo4j, I get validator errors when I attempt to access Neo4jTemplate:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'indexController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.data.neo4j.support.Neo4jTemplate org.neuralsandbox.controllers.IndexController.neo4jTemplate; nested exception is java.lang.NoClassDefFoundError: javax/validation/Validator
Is there any way to resolve this?
One possible option, especially when you actually need
javax.validationfunctionality, is to add an implementation ofjavax.validation(such as Hibernate Validator) to the classpath.If you don’t need
javax.validation, you should be able to suppress this error by creating a dummyorg.springframework.validation.Validatorand configuring it as<mvc:annotation-driver validator = "..." />.