Bean -Validierung funktioniert nicht nach der Aktualisierung auf Spring Boot 3Java

Java-Forum
Anonymous
 Bean -Validierung funktioniert nicht nach der Aktualisierung auf Spring Boot 3

Post by Anonymous »

Nach der Aktualisierung von Spring Boot 3 erhalte ich die folgende Ausnahme, während die Bean -Validierung verwendet wird: < /p>

Code: Select all

java.lang.IllegalStateException:  Failed to load ApplicationContext for [MergedContextConfiguration@54089484 testClass = com.sogh.rest.EventFeedClientTest, locations = [], classes = [], contextInitializerClasses = [], activeProfiles = [], propertySourceLocations = [], propertySourceProperties = ["rest.endpoints.query.backoff=1000"], contextCustomizers = [[ImportsContextCustomizer@45adc393 key = [com.sogh.utils.TestConfig, com.globalrelay.mc.oscar.common.logging.LoggingConfiguration, com.sogh.rest.RestApiConfig]], org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@437da279, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@6253c26, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@254ea8f8, org.springframework.boot.test.autoconfigure.actuate.observability.ObservabilityContextCustomizerFactory$DisableObservabilityContextCustomizer@9da1, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@69e153c5], contextLoader = org.springframework.test.context.support.DelegatingSmartContextLoader,  p a r e n t   =   n u l l ] < b r   / > < b r   / >         a t   o r g . s p r i n g f r a m e w o r k . t e s t . c o n t e x t . c a c h e . D e f a u l t C a c h e A w a r e C o n t e x t L o a d e r D e l e g a t e . l o a d C o n t e x t ( D e f a u l t C a c h e A w a r e C o n t e x t L o a d e r D e l e g a t e . j a v a : 1 4 2 ) < b r   / >         a t   o r g . s p r i n g f r a m e w o r k . t e s t . c o n t e x t . s u p p o r t . D e f a u l t T e s t C o n t e x t . g e t A p p l i c a t i o n C o n t e x t ( D e f a u l t T e s t C o n t e x t . j a v a : 1 2 7 ) < b r   / >         a t   o r g . s p r i n g f r a m e w o r k . b o o t . t e s t . m o c k . m o c k i t o . M o c k i t o T e s t E x e c u t i o n L i s t e n e r . p o s t P r o c e s s F i e l d s ( M o c k i t o T e s t E x e c u t i o n L i s t e n e r . j a v a : 1 1 0 ) < b r   / >         a t   o r g . s p r i n g f r a m e w o r k . b o o t . t e s t . m o c k . m o c k i t o . M o c k i t o T e s t E x e c u t i o n L i s t e n e r . i n j e c t F i e l d s ( M o c k i t o T e s t E x e c u t i o n L i s t e n e r . j a v a : 9 4 ) < b r   / >         a t   o r g . s p r i n g f r a m e w o r k . b o o t . t e s t . m o c k . m o c k i t o . M o c k i t o T e s t E x e c u t i o n L i s t e n e r . p r e p a r e T e s t I n s t a n c e ( M o c k i t o T e s t E x e c u t i o n L i s t e n e r . j a v a : 6 1 ) < b r   / >         a t   o r g . s p r i n g f r a m e w o r k . t e s t . c o n t e x t . T e s t C o n t e x t M a n a g e r . p r e p a r e T e s t I n s t a n c e ( T e s t C o n t e x t M a n a g e r . j a v a : 2 4 1 ) < b r   / >         a t   o r g . s p r i n g f r a m e w o r k . t e s t . c o n t e x t . j u n i t . j u p i t e r . S p r i n g E x t e n s i o n . p o s t P r o c e s s T e s t I n s t a n c e ( S p r i n g E x t e n s i o n . j a v a : 1 3 8 ) < b r   / >         a t   o r g . j u n i t . j u p i t e r . e n g i n e . d e s c r i p t o r . C l a s s B a s e d T e s t D e s c r i p t o r . l a m b d a $ i n v o k e T e s t I n s t a n c e P o s t P r o c e s s o r s $ 1 0 ( C l a s s B a s e d T e s t D e s c r i p t o r . j a v a : 3 7 7 ) < b r   / >         a t   o r g . j u n i t . j u p i t e r . e n g i n e . d e s c r i p t o r . C l a s s B a s e d T e s t D e s c r i p t o r . e x e c u t e A n d M a s k T h r o w a b l e ( C l a s s B a s e d T e s t D e s c r i p t o r . j a v a : 3 8 2 ) < b r   / >         a t   o r g . j u n i t . j u p i t e r . e n g i n e . d e s c r i p t o r . C l a s s B a s e d T e s t D e s c r i p t o r . l a m b d a $ i n v o k e T e s t I n s t a n c e P o s t P r o c e s s o r s $ 1 1 ( C l a s s B a s e d T e s t D e s c r i p t o r . j a v a : 3 7 7 ) < b r   / >         a t   j a v a . b a s e / j a v a . u t i l . s t r e a m . R e f e r e n c e P i p e l i n e $ 3 $ 1 . a c c e p t ( R e f e r e n c e P i p e l i n e . j a v a : 1 9 7 ) < b r   / >         a t   j a v a . b a s e / j a v a . u t i l . s t r e a m . R e f e r e n c e P i p e l i n e $ 2 $ 1 . a c c e p t ( R e f e r e n c e P i p e l i n e . j a v a : 1 7 9 ) < b r   / >         a t   j a v a . b a s e / j a v a . u t i l . A r r a y L i s t $ A r r a y L i s t S p l i t e r a t o r . f o r E a c h R e m a i n i n g ( A r r a y L i s t . j a v a : 1 6 2 5 ) < b r   / >         a t   j a v a . b a s e / j a v a . u t i l . s t r e a m . A b s t r a c t P i p e l i n e . c o p y I n t o ( A b s t r a c t P i p e l i n e . j a v a : 5 0 9 ) < b r   / >         a t   j a v a . b a s e / j a v a . u t i l . s t r e a m . A b s t r a c t P i p e l i n e . w r a p A n d C o p y I n t o ( A b s t r a c t P i p e l i n e . j a v a : 4 9 9 ) < b r   / >         a t   j a v a . b a s e / j a v a . u t i l . s t r e a m . S t r e a m S p l i t e r a t o r s $ W r a p p i n g S p l i t e r a t o r . f o r E a c h R e m a i n i n g ( S t r e a m S p l i t e r a t o r s . j a v a : 3 1 0 ) < b r   / >         a t   j a v a . b a s e / j a v a . u t i l . s t r e a m . S t r e a m s $ C o n c a t S p l i t e r a t o r . f o r E a c h R e m a i n i n g ( S t r e a m s . j a v a : 7 3 5 ) < b r   / >         a t   j a v a . b a s e / j a v a . u t i l . s t r e a m . S t r e a m s $ C o n c a t S p l i t e r a t o r . f o r E a c h R e m a i n i n g ( S t r e a m s . j a v a : 7 3 4 ) < b r   / >         a t   j a v a . b a s e / j a v a . u t i l . s t r e a m . R e f e r e n c e P i p e l i n e $ H e a d . f o r E a c h ( R e f e r e n c e P i p e l i n e . j a v a : 7 6 2 ) < b r   / >         a t   o r g . j u n i t . j u p i t e r . e n g i n e . d e s c r i p t o r . C l a s s B a s e d T e s t D e s c r i p t o r . i n v o k e T e s t I n s t a n c e P o s t P r o c e s s o r s ( C l a s s B a s e d T e s t D e s c r i p t o r . j a v a : 3 7 6 ) < b r   / >         a t   o r g . j u n i t . j u p i t e r . e n g i n e . d e s c r i p t o r . C l a s s B a s e d T e s t D e s c r i p t o r . l a m b d a $ i n s t a n t i a t e A n d P o s t P r o c e s s T e s t I n s t a n c e $ 6 ( C l a s s B a s e d T e s t D e s c r i p t o r . j a v a : 2 8 9 ) < b r   / >         a t   o r g . j u n i t . p l a t f o r m . e n g i n e . s u p p o r t . h i e r a r c h i c a l . T h r o w a b l e C o l l e c t o r . e x e c u t e ( T h r o w a b l e C o l l e c t o r . j a v a : 7 3 ) < b r   / >         a t   o r g . j u n i t . j u p i t e r . e n g i n e . d e s c r i p t o r . C l a s s B a s e d T e s t D e s c r i p t o r . i n s t a n t i a t e A n d P o s t P r o c e s s T e s t I n s t a n c e ( C l a s s B a s e d T e s t D e s c r i p t o r . j a v a : 2 8 8 ) < b r   / >         a t   o r g . j u n i t . j u p i t e r . e n g i n e . d e s c r i p t o r . C l a s s B a s e d T e s t D e s c r i p t o r . l a m b d a $ t e s t I n s t a n c e s P r o v i d e r $ 4 ( C l a s s B a s e d T e s t D e s c r i p t o r . j a v a : 2 7 8 ) < b r   / >         a t   j a v a . b a s e / j a v a . u t i l . O p t i o n a l . o r E l s e G e t ( O p t i o n a l . j a v a : 3 6 4 ) < b r   / >         a t   o r g . j u n i t . j u p i t e r . e n g i n e . d e s c r i p t o r . C l a s s B a s e d T e s t D e s c r i p t o r . l a m b d a $ t e s t I n s t a n c e s P r o v i d e r $ 5 ( C l a s s B a s e d T e s t D e s c r i p t o r . j a v a : 2 7 7 ) < b r   / >         a t   o r g . j u n i t . j u p i t e r . e n g i n e . e x e c u t i o n . T e s t I n s t a n c e s P r o v i d e r . g e t T e s t I n s t a n c e s ( T e s t I n s t a n c e s P r o v i d e r . j a v a : 3 1 ) < b r   / >         a t   o r g . j u n i t . j u p i t e r . e n g i n e . d e s c r i p t o r . T e s t M e t h o d T e s t D e s c r i p t o r . l a m b d a $ p r e p a r e $ 0 ( T e s t M e t h o d T e s t D e s c r i p t o r . j a v a : 1 0 5 ) < b r   / >         a t   o r g . j u n i t . p l a t f o r m . e n g i n e . s u p p o r t . h i e r a r c h i c a l . T h r o w a b l e C o l l e c t o r . e x e c u t e ( T h r o w a b l e C o l l e c t o r . j a v a : 7 3 ) < b r   / >         a t   o r g . j u n i t . j u p i t e r . e n g i n e . d e s c r i p t o r . T e s t M e t h o d T e s t D e s c riptor.prepare(TestMethodTestDescriptor.java:104)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:68)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$prepare$2(NodeTestTask.java:123)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.prepare(NodeTestTask.java:123)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:90)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:147)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:127)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:90)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:55)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:102)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:54)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57)
at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55)
Caused by:  org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'eventFeedClient' defined in class path resource [com/globalrelay/mc/oscar/common/normalizer/service/rest/RestApiConfig.class]: Failed to instantiate [com.sogh.rest.EventFeedClient]: Factory method 'eventFeedClient' threw exception with message: Unable to create a Configuration, because no Bean Validation provider could be found. Add a provider like Hibernate Validator (RI) to your classpath.
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:657)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:645)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1332)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1162)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:560)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:973)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:917)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:584)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:221)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:110)
at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:212)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:184)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:118)
... 73 more
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.sogh.rest.EventFeedClient]: Factory method 'eventFeedClient' threw exception with message: Unable to create a Configuration, because no Bean Validation provider could be found. Add a provider like Hibernate Validator (RI) to your classpath.
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:171)
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
... 90 more
Caused by: javax.validation.NoProviderFoundException: 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:291)
at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:103)
at com.sogh.rest.AbstractRestClient.(AbstractRestClient.java:42)
at com.sogh.rest.EventFeedClient.(EventFeedClient.java:30)
at com.sogh.rest.RestApiConfig.eventFeedClient(RestApiConfig.java:76)
at com.sogh.rest.RestApiConfig$$SpringCGLIB$$0.CGLIB$eventFeedClient$1()
at com.sogh.RestApiConfig$$SpringCGLIB$$2.invoke()
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:258)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331)
at com.sogh.RestApiConfig$$SpringCGLIB$$0.eventFeedClient()
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:139)
... 91 more
< /code>
Dies ist die Codezeile, auf der er fehlschlägt: < /p>
private final Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
< /code>
Ich habe die folgenden Abhängigkeiten in Maven konfiguriert: < /p>
    
javax.validation
validation-api
2.0.1.Final


org.hibernate.validator
hibernate-validator
8.0.0.Final


org.springframework.boot
spring-boot-starter-validation
3.0.5


jakarta.validation
jakarta.validation-api
3.0.2

Was fehlt mir?

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post