Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring mvc 嵌套异常为java.lang.NoClassDefFoundError:无法初始化类org.hibernate.validator.internal.engine.ConfigurationImpl_Spring Mvc_Servlets_Hibernate Validator_Spring Validator - Fatal编程技术网

Spring mvc 嵌套异常为java.lang.NoClassDefFoundError:无法初始化类org.hibernate.validator.internal.engine.ConfigurationImpl

Spring mvc 嵌套异常为java.lang.NoClassDefFoundError:无法初始化类org.hibernate.validator.internal.engine.ConfigurationImpl,spring-mvc,servlets,hibernate-validator,spring-validator,Spring Mvc,Servlets,Hibernate Validator,Spring Validator,当我在getParam中实现@NotNull@NotEmpty注释验证程序时,其原因错误为: public ModelAndView Details(@ModelAttribute("") @Validated App app, BindingResult result, @RequestParam(value="paramSessionAttr", required=false) String sessionAttr, @RequestParam("paramAction") @NotNul

当我在getParam中实现
@NotNull
@NotEmpty
注释验证程序时,其原因错误为:

 public ModelAndView Details(@ModelAttribute("") @Validated App app, BindingResult result, @RequestParam(value="paramSessionAttr", required=false) String sessionAttr, @RequestParam("paramAction") @NotNull @NotEmpty String param_action){ ... }
使用
hibernate-validator-5.2.2.jar
tomcat8.0
spring-4.2.3.jar

当我导入javax.validator时,它是
validation-api-1.1.0.jar[JSR-349]
它导致了这个错误

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'appController' defined in file [C:\apache-tomcat-8.0.29\wtpwebapps\Application Portal\WEB-INF\classes\com\controller\AppController.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.controller.AppController]: Constructor threw exception; nested exception is java.lang.Error: Unresolved compilation problems: 
The type javax.validation.Payload cannot be resolved. It is indirectly referenced from required .class files
The import javax.validation cannot be resolved
当我删除
@NotNull
@NotEmpty
验证-api-1.1.0。最终
工作正常

当我导入
validation-api-1.1.0.final时,没有
@NotNull
@NotEmpty
我得到了这个错误

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean#0': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.internal.engine.ConfigurationImpl
我尝试从其他源下载并导入
validation-api-1.1.0。最终的
我也得到了与上面相同的错误

我在
hibernate-validator-5.2.2-Final.jar中找到了
org.hibernate.validator.internal.engine.configurationmpl

servlet可能的bean配置缺少什么

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean#0': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.internal.engine.ConfigurationImpl

/WEB/INF/messages
导入的库

  • hibernate-validator-5.2.2.Final.jar
  • hibernate-validator-annotation-processor-5.2.2.Final.jar
  • hibernate-validator-cdi-5.2.2.Final.jar
  • javax.el-api-3.0.0.jar
  • jboss-logging.jar
  • spring-context-4.2.3.RELEASE.jar
  • spring-beans-4.2.3.RELEASE.jar
  • validation-api-1.1.0.final.jar
  • 同学-1.3.1.jar
  • slf4j-jdk14-1.7.13.jar
参考资料


我想有些库不见了,因为我按顺序下载了库

您可以作为软件包从下载,而不是按单点下载

设置指南

在项目中导入并包含下面的库

  • 同学-1.1.0.jar
  • javax.el-2.2.4.jar
  • javax.el-api-2.2.4.jar
  • jboss-logging-3.2.1.Final.jar
  • validation-api-1.1.0.Final.jar
  • hibernate-validator-5.2.2.Final.jar
  • hibernate-validator-annotation-processor-5.2.2.Final.jar
  • hibernate-validator-cdi-5.2.2.Final.jar

那么你的代码应该可以工作了

我猜有些库丢失了,因为我按顺序下载了库

您可以作为软件包从下载,而不是按单点下载

设置指南

在项目中导入并包含下面的库

  • 同学-1.1.0.jar
  • javax.el-2.2.4.jar
  • javax.el-api-2.2.4.jar
  • jboss-logging-3.2.1.Final.jar
  • validation-api-1.1.0.Final.jar
  • hibernate-validator-5.2.2.Final.jar
  • hibernate-validator-annotation-processor-5.2.2.Final.jar
  • hibernate-validator-cdi-5.2.2.Final.jar

那么你的代码应该可以工作了

可能会发生冲突

就我的情况而言:

jboss.common:jboss common:jar:1.2.1.GA
org.jboss.logging:jbosslogging:jar:3.3.0.Final

同时存在,但它们有相同的包“org.jboss.logging”


只要在pom.xml中排除一个,可能会发生库冲突

就我的情况而言:

jboss.common:jboss common:jar:1.2.1.GA
org.jboss.logging:jbosslogging:jar:3.3.0.Final

同时存在,但它们有相同的包“org.jboss.logging”


只需在pom.xml中排除一个,我使用sts生成spring项目。我得到了上面的错误。花了两天时间,我想调整版本可以解决问题

在pom.xml的父部分中,我将1.5.4替换为1.2.5

<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:context="http://www.springframework.org/schema/context"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:mvc="http://www.springframework.org/schema/mvc"
   xsi:schemaLocation="
   http://www.springframework.org/schema/beans     
   http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
   http://www.springframework.org/schema/context 
   http://www.springframework.org/schema/context/spring-context-3.0.xsd
   http://www.springframework.org/schema/mvc
   http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">

   <context:component-scan base-package="com.controller" />

   <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
      <property name="prefix" value="/WEB-INF/jsp/" />
      <property name="suffix" value=".jsp" />
   </bean>

    <bean class="org.springframework.context.support.ResourceBundleMessageSource">
        <property name="basenames">
            <list>
                <value>/WEB/INF/messages</value>
            </list>
        </property>
        <property name="defaultEncoding" value="UTF-8" />
   </bean> 

    <!--<bean id="validator" class="org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean" />  -->


    <mvc:default-servlet-handler/>
    <mvc:resources mapping="/resources/**" location="/resources/" cache-period="31556926"/>
    <mvc:annotation-driven />
</beans>

org.springframework.boot
spring启动程序父级
1.2.5.1发布

我使用sts生成spring项目。我得到了上面的错误。花了两天时间,我想调整版本可以解决问题

在pom.xml的父部分中,我将1.5.4替换为1.2.5

<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:context="http://www.springframework.org/schema/context"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:mvc="http://www.springframework.org/schema/mvc"
   xsi:schemaLocation="
   http://www.springframework.org/schema/beans     
   http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
   http://www.springframework.org/schema/context 
   http://www.springframework.org/schema/context/spring-context-3.0.xsd
   http://www.springframework.org/schema/mvc
   http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">

   <context:component-scan base-package="com.controller" />

   <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
      <property name="prefix" value="/WEB-INF/jsp/" />
      <property name="suffix" value=".jsp" />
   </bean>

    <bean class="org.springframework.context.support.ResourceBundleMessageSource">
        <property name="basenames">
            <list>
                <value>/WEB/INF/messages</value>
            </list>
        </property>
        <property name="defaultEncoding" value="UTF-8" />
   </bean> 

    <!--<bean id="validator" class="org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean" />  -->


    <mvc:default-servlet-handler/>
    <mvc:resources mapping="/resources/**" location="/resources/" cache-period="31556926"/>
    <mvc:annotation-driven />
</beans>

org.springframework.boot
spring启动程序父级
1.2.5.1发布

我在使用JSR303bean验证时遇到了同样的问题,我在下面添加了两个jar(以及validation-api-1.1.0.final.jarhibernate-validator-5.0.1.final.jar),问题得到了解决


1.classmate-0.8.0.jar2.jboss-logging-3.1.0.ga.jar在使用JSR 303 bean验证时,我遇到了同样的问题,我在下面添加了两个jar(以及validation-api-1.1.0.final.jarhibernate-validator-5.0.1.final.jar),问题得到了解决


1.classmate-0.8.0.jar2.jboss-logging-3.1.0.ga.jar

出于某种原因,我在本地maven repo中得到了一个无效条目。对我来说,这导致了这个例外的发生。Maven发出警告
[warning]org.hibernate.validator:hibernate validator:jar:6.0.11.Final的POM无效…
出于某种原因,我在本地Maven repo中得到了一个无效条目。对我来说,这导致了这个例外的发生。Maven发出警告
[警告]org.hibernate.validator:hibernate validator:jar:6.0.11.Final的POM无效…