zoukankan      html  css  js  c++  java
  • javax.validation.ValidationException: Unable to create a Configuration, because no Bean Validation provider could be found. Add a provider like Hibernate Validator (RI) to your classpath.

     项目依赖 

    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
    </dependency>

     出现问题

    10:13:27.702 [localhost-startStop-1] DEBUG org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean - Failed to set up a Bean Validation provider
    javax.validation.ValidationException: Unable to create a Configuration, because no Bean Validation provider could be found. Add a provider like Hibernate Validator (RI) to your classpath.
    	at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:271)
    	at org.springframework.validation.beanvalidation.LocalValidatorFactoryBean.afterPropertiesSet(LocalValidatorFactoryBean.java:248)
    	at org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean.afterPropertiesSet(OptionalValidatorFactoryBean.java:40)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
    	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
    	at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668)
    	at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634)
    	at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682)
    	at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553)
    	at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494)
    	at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
    	at javax.servlet.GenericServlet.init(GenericServlet.java:158)
    	at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1227)
    	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1140)
    	at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1027)
    	at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5038)
    	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5348)
    	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
    	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
    	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    	at java.lang.Thread.run(Thread.java:745)
    

      

    问题解决

    The javaee dependencies includes the javax.validation packages, 
    which in turn trigger the automatic registration of a JSR-303 bean validation. 
    But the javaee only has the API not an implementation for it. 
    Either add an implementation or don't use the fat javaee jar as a dependency. 
    Also it isn't an error it is a debug message, telling you a provider cannot be found,
     your application should start regardless of that.
    

     

    汉译

    javaee依赖关系包括javax.validation程序包,
    从而触发JSR-303 Bean验证的自动注册。 
    但是,javaee只有API不是一个实现。
     添加一个实现或者不要使用javaee jar作为依赖。
     此外,它不是一个错误,它是一个调试消息,告诉您不能找到提供程序,您的应用程序应该开始,可以忽略这个提示。
    

      

  • 相关阅读:
    MySQL如何查询两个日期之间的记录
    Android常用权限
    Android如何区别真机和模拟器
    android资源文件说明
    Android文件存取路径
    @SuppressLint("NewApi")和@TargetApi()的区别
    Java注释规范
    启动IpFilterDriver驱动
    IDEA 创建 Spring Boot 多模块项目(Multi Modules)
    Spring Boot 多环境如何配置
  • 原文地址:https://www.cnblogs.com/tijun/p/7680329.html
Copyright © 2011-2022 走看看