我想创建一个将 Neo4j 与 Spring Data 结合使用的 Web 应用程序。我正在使用 Maven 来处理依赖项和构建,但由于spring-data-neo4j
.
当我包含 spring-data-neo4j 时,它包含javax.validation
,但是当包含它时,我在使用<mvc:annotation-driven />
@Controller 和 @RequestMapping 注释时遇到问题,这会导致此问题:
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
如果我从 中排除javax.validation
作为依赖项,则spring-data-neo4j
在尝试访问时会收到验证器错误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
有没有办法解决这个问题?