我在堆栈溢出中找到了三个条目:
javax.validation.ValidationException:无法找到默认提供程序
javax.validation.ValidationException:无法找到默认提供程序
并且所有三个人都说将hibernate验证器添加到类路径中.当我这样做并仍然得到相同的错误时我该怎么办?
1301 [main] ERROR org.springframework.web.servlet.DispatcherServlet - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/db.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to get the default Bean Validation factory
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:631)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:588)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:645)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:508)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:449)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:133)
at javax.servlet.GenericServlet.init(GenericServlet.java:241) …Run Code Online (Sandbox Code Playgroud) 经过几个小时的谷歌和一些教程,我被打败了...事实并非我得到错误可以给我提示问题是什么,完全没有它们让我疯了!
以下代码有效,只是不应该!检查输入不是null或小于3个字符长的注释永远不会运行.在部署项目或写入名称变量时,它们也不会发出任何错误.
public class testBean
{
@NotNull
@Size(min=3)
private String name;
}
public void test()
{
System.out.println(name);
}
Run Code Online (Sandbox Code Playgroud)
输入表格:
<h:form>
<h:inputText value="#{testBean.name}" />
<h:commandButton value="Send" action="#{testBean.test()}" />
</h:form>
Run Code Online (Sandbox Code Playgroud)
我的猜测是,这是导致问题的tomcat,虽然我很确定我已经导入了所有必要的库.对于我正在使用的IDE,Eclipse也是如此.