gpt4 book ai didi

java - com.springsource.org.springmodules.validation.validator 0.9.0 有更新的替代品吗?

转载 作者:行者123 更新时间:2023-12-02 02:44:50 28 4
gpt4 key购买 nike

我有一个遗留的 Spring 应用程序需要维护。该应用程序使用spring框架和spring beanutils。我正在升级到 4.x。但是,当我在jetty上运行时,我发现这个错误

java.lang.NoSuchMethodError: org.springframework.util.ClassUtils.forName(Ljava/lang/String;)Ljava/lang/Class;
at org.springmodules.validation.util.LibraryUtils.isClassInClasspath(LibraryUtils.java:56)
at org.springmodules.validation.util.LibraryUtils.<clinit>(LibraryUtils.java:30)
at org.springmodules.validation.bean.conf.loader.annotation.DefaultValidationAnnotationHandlerRegistry.<init>(DefaultValidationAnnotationHandlerRegistry.java:115)
at org.springmodules.validation.bean.conf.loader.annotation.AnnotationBeanValidationConfigurationLoader.<init>(AnnotationBeanValidationConfigurationLoader.java:82)
at org.springmodules.validation.bean.conf.loader.annotation.AnnotationBeanValidationConfigurationLoader.<init>(AnnotationBeanValidationConfigurationLoader.java:69)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:142)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:89)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1147)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1099)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
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:867)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:835)
at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:530)
at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:808)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:342)
at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1379)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1341)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:772)
at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:259)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:517)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
at org.eclipse.jetty.server.Server.start(Server.java:405)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:106)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
at org.eclipse.jetty.server.Server.doStart(Server.java:372)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at runjettyrun.Bootstrap.main(Bootstrap.java:89)

我发现函数 ClassUtils.forName(String) 在 SpringFraemwork 3 中已被弃用,并且在 4 中不再存在。

我可以找到 springmodules validation jar 0.9.0 的更新替代品吗? ?

新函数不应调用此函数,而应调用 ClassUtils.forName(String, ClassLoader)。

它包含在新的 Spring jar 中吗?

我注意到一个叫做 Hibernate-validator 的东西,我不确定这是否有帮助。

最佳答案

已经过去一年了,但我正在回答这个问题,考虑到是否有人仍然需要该解决方案。最近,我在应用程序中使用 Bean Validation 1.0 (JSR-303)Bean Validation 1.1 (JSR-349) 替换了 spring-modules-validation 作为替代解决方案。我的应用程序使用 Spring Framework 4。我已将 spring-modules-validation 的依赖项替换为 javax.validation:validation-apiorg.hibernate.validator :hibernate-validator.

关于实现,这取决于您想要替换的 bean validator ,例如 @Lengthorg.springmodules.validation.bean.conf.loader.annotation.handler.Length可以替换为@Sizejavax.validation.constraints.Size .同样@NotBlankorg.springmodules.validation.bean.conf.loader.annotation.handler.NotBlank可以替换为@NotBlankjavax.validation.constraints.NotBlank您可以使用类 org.springframework.validation.beanvalidation.LocalValidatorFactoryBean 创建 validator bean而不是org.springmodules.validation.bean.BeanValidator .

请注意,这些只是 JSR 303 中可用的一些注释。此外,Hibernate Validator 还引入了一些自己的注释。请查找 spring 文档 here

关于java - com.springsource.org.springmodules.validation.validator 0.9.0 有更新的替代品吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44781884/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com