Spring junit4单元测试出现异常:java.lang.IllegalStateException: Failed to load ApplicationContext
1 出错如下
[WARN ] 2019-03-06 14:13:36,077 method:org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544)
Exception encountered during context initialization - cancelling refresh attempt
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘defaultServletHandlerMapping’ defined in class path resource [org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method ‘defaultServletHandlerMapping’ threw exception; nested exception is java.lang.IllegalArgumentException: A ServletContext is required to configure default servlet handling
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:305)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:834)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:125)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:60)
at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:109)
at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:261)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:98)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:116)
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:117)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:228)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:217)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:276)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:278)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:236)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:87)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner
2.
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
>
a
t
c
o
m
.
i
n
t
e
l
l
i
j
.
j
u
n
i
t
4.
J
U
n
i
t
4
I
d
e
a
T
e
s
t
R
u
n
n
e
r
.
s
t
a
r
t
R
u
n
n
e
r
W
i
t
h
A
r
g
s
(
J
U
n
i
t
4
I
d
e
a
T
e
s
t
R
u
n
n
e
r
.
j
a
v
a
:
68
)
<
b
r
/
>
a
t
c
o
m
.
i
n
t
e
l
l
i
j
.
r
t
.
e
x
e
c
u
t
i
o
n
.
j
u
n
i
t
.
I
d
e
a
T
e
s
t
R
u
n
n
e
r
2.evaluate(ParentRunner.java:229)<br /> at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)<br /> at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)<br /> at org.junit.runners.ParentRunner.run(ParentRunner.java:309)<br /> at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)<br /> at org.junit.runner.JUnitCore.run(JUnitCore.java:160)<br /> at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)<br /> at com.intellij.rt.execution.junit.IdeaTestRunner
2.evaluate(ParentRunner.java:229)<br/>atorg.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)<br/>atorg.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)<br/>atorg.junit.runners.ParentRunner.run(ParentRunner.java:309)<br/>atorg.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)<br/>atorg.junit.runner.JUnitCore.run(JUnitCore.java:160)<br/>atcom.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)<br/>atcom.intellij.rt.execution.junit.IdeaTestRunnerRepeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method ‘defaultServletHandlerMapping’ threw exception; nested exception is java.lang.IllegalArgumentException: A ServletContext is required to configure default servlet handling
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
… 41 more
Caused by: java.lang.IllegalArgumentException: A ServletContext is required to configure default servlet handling
at org.springframework.util.Assert.notNull(Assert.java:115)
at org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer.(DefaultServletHandlerConfigurer.java:53)
at org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport.defaultServletHandlerMapping(WebMvcConfigurationSupport.java:450)
at org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration
E
n
h
a
n
c
e
r
B
y
S
p
r
i
n
g
C
G
L
I
B
EnhancerBySpringCGLIB
EnhancerBySpringCGLIB87050dba.CGLIB$defaultServletHandlerMapping
27
(
<
g
e
n
e
r
a
t
e
d
>
)
<
b
r
/
>
a
t
o
r
g
.
s
p
r
i
n
g
f
r
a
m
e
w
o
r
k
.
w
e
b
.
s
e
r
v
l
e
t
.
c
o
n
f
i
g
.
a
n
n
o
t
a
t
i
o
n
.
D
e
l
e
g
a
t
i
n
g
W
e
b
M
v
c
C
o
n
f
i
g
u
r
a
t
i
o
n
27(<generated>)<br /> at org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration
27(<generated>)<br/>atorg.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration
E
n
h
a
n
c
e
r
B
y
S
p
r
i
n
g
C
G
L
I
B
EnhancerBySpringCGLIB
EnhancerBySpringCGLIB
87050
d
b
a
87050dba
87050dba
F
a
s
t
C
l
a
s
s
B
y
S
p
r
i
n
g
C
G
L
I
B
FastClassBySpringCGLIB
FastClassBySpringCGLIB
120
f
7
a
5
f
.
i
n
v
o
k
e
(
<
g
e
n
e
r
a
t
e
d
>
)
<
b
r
/
>
a
t
o
r
g
.
s
p
r
i
n
g
f
r
a
m
e
w
o
r
k
.
c
g
l
i
b
.
p
r
o
x
y
.
M
e
t
h
o
d
P
r
o
x
y
.
i
n
v
o
k
e
S
u
p
e
r
(
M
e
t
h
o
d
P
r
o
x
y
.
j
a
v
a
:
228
)
<
b
r
/
>
a
t
o
r
g
.
s
p
r
i
n
g
f
r
a
m
e
w
o
r
k
.
c
o
n
t
e
x
t
.
a
n
n
o
t
a
t
i
o
n
.
C
o
n
f
i
g
u
r
a
t
i
o
n
C
l
a
s
s
E
n
h
a
n
c
e
r
120f7a5f.invoke(<generated>)<br /> at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)<br /> at org.springframework.context.annotation.ConfigurationClassEnhancer
120f7a5f.invoke(<generated>)<br/>atorg.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)<br/>atorg.springframework.context.annotation.ConfigurationClassEnhancerBeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:318)
at org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration
E
n
h
a
n
c
e
r
B
y
S
p
r
i
n
g
C
G
L
I
B
EnhancerBySpringCGLIB
EnhancerBySpringCGLIB87050dba.defaultServletHandlerMapping()
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
… 42 more
[DEBUG] 2019-03-06 14:13:36,085 method:org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:512)
Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@436a4e4b: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.event.internalEventListenerProcessor,org.springframework.context.event.internalEventListenerFactory,adminDao,sensorDao,sensorGridDao,loginService,sensorService,emailUtils,excelExportUtil,loginController,sensorController,webConfig,org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor#0,dataSource,jdbcTemplate,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor,org.springframework.context.annotation.ConfigurationClassPostProcessor.enhancedConfigurationProcessor,org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration,requestMappingHandlerMapping,mvcContentNegotiationManager,viewControllerHandlerMapping,beanNameHandlerMapping,resourceHandlerMapping,mvcResourceUrlProvider,defaultServletHandlerMapping,requestMappingHandlerAdapter,mvcConversionService,mvcValidator,mvcPathMatcher,mvcUrlPathHelper,mvcUriComponentsContributor,httpRequestHandlerAdapter,simpleControllerHandlerAdapter,handlerExceptionResolver,mvcViewResolver,viewResolver]; root of factory hierarchy
[DEBUG] 2019-03-06 14:13:36,087 method:org.springframework.beans.factory.support.DisposableBeanAdapter.invokeCustomDestroyMethod(DisposableBeanAdapter.java:326)
Invoking destroy method ‘close’ on bean with name ‘dataSource’
[ERROR] 2019-03-06 14:13:36,092 method:org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:231)
Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@6d00a15d] to prepare test instance [com.sensor.dao.SensorGridDaoTest@3532ec19]
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:117)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:228)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:217)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:276)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:278)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:236)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:87)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner
2.
e
v
a
l
u
a
t
e
(
P
a
r
e
n
t
R
u
n
n
e
r
.
j
a
v
a
:
229
)
<
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
4.
s
t
a
t
e
m
e
n
t
s
.
R
u
n
B
e
f
o
r
e
T
e
s
t
C
l
a
s
s
C
a
l
l
b
a
c
k
s
.
e
v
a
l
u
a
t
e
(
R
u
n
B
e
f
o
r
e
T
e
s
t
C
l
a
s
s
C
a
l
l
b
a
c
k
s
.
j
a
v
a
:
61
)
<
b
r
/
>
a
t
o
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eforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)<br /> at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)<br /> at org.junit.runners.ParentRunner.run(ParentRunner.java:309)<br /> at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)<br /> at org.junit.runner.JUnitCore.run(JUnitCore.java:160)<br /> at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)<br /> at com.intellij.rt.execution.junit.IdeaTestRunner
2.evaluate(ParentRunner.java:229)<br/>atorg.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)<br/>atorg.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)<br/>atorg.junit.runners.ParentRunner.run(ParentRunner.java:309)<br/>atorg.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)<br/>atorg.junit.runner.JUnitCore.run(JUnitCore.java:160)<br/>atcom.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)<br/>atcom.intellij.rt.execution.junit.IdeaTestRunnerRepeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘defaultServletHandlerMapping’ defined in class path resource [org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method ‘defaultServletHandlerMapping’ threw exception; nested exception is java.lang.IllegalArgumentException: A ServletContext is required to configure default servlet handling
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory
1.
g
e
t
O
b
j
e
c
t
(
A
b
s
t
r
a
c
t
B
e
a
n
F
a
c
t
o
r
y
.
j
a
v
a
:
305
)
<
b
r
/
>
a
t
o
r
g
.
s
p
r
i
n
g
f
r
a
m
e
w
o
r
k
.
b
e
a
n
s
.
f
a
c
t
o
r
y
.
s
u
p
p
o
r
t
.
D
e
f
a
u
l
t
S
i
n
g
l
e
t
o
n
B
e
a
n
R
e
g
i
s
t
r
y
.
g
e
t
S
i
n
g
l
e
t
o
n
(
D
e
f
a
u
l
t
S
i
n
g
l
e
t
o
n
B
e
a
n
R
e
g
i
s
t
r
y
.
j
a
v
a
:
230
)
<
b
r
/
>
a
t
o
r
g
.
s
p
r
i
n
g
f
r
a
m
e
w
o
r
k
.
b
e
a
n
s
.
f
a
c
t
o
r
y
.
s
u
p
p
o
r
t
.
A
b
s
t
r
a
c
t
B
e
a
n
F
a
c
t
o
r
y
.
d
o
G
e
t
B
e
a
n
(
A
b
s
t
r
a
c
t
B
e
a
n
F
a
c
t
o
r
y
.
j
a
v
a
:
301
)
<
b
r
/
>
a
t
o
r
g
.
s
p
r
i
n
g
f
r
a
m
e
w
o
r
k
.
b
e
a
n
s
.
f
a
c
t
o
r
y
.
s
u
p
p
o
r
t
.
A
b
s
t
r
a
c
t
B
e
a
n
F
a
c
t
o
r
y
.
g
e
t
B
e
a
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f
a
u
l
t
S
e
r
v
l
e
t
H
a
n
d
l
e
r
C
o
n
f
i
g
u
r
e
r
.
<
i
n
i
t
>
(
D
e
f
a
u
l
t
S
e
r
v
l
e
t
H
a
n
d
l
e
r
C
o
n
f
i
g
u
r
e
r
.
j
a
v
a
:
53
)
<
b
r
/
>
a
t
o
r
g
.
s
p
r
i
n
g
f
r
a
m
e
w
o
r
k
.
w
e
b
.
s
e
r
v
l
e
t
.
c
o
n
f
i
g
.
a
n
n
o
t
a
t
i
o
n
.
W
e
b
M
v
c
C
o
n
f
i
g
u
r
a
t
i
o
n
S
u
p
p
o
r
t
.
d
e
f
a
u
l
t
S
e
r
v
l
e
t
H
a
n
d
l
e
r
M
a
p
p
i
n
g
(
W
e
b
M
v
c
C
o
n
f
i
g
u
r
a
t
i
o
n
S
u
p
p
o
r
t
.
j
a
v
a
:
450
)
<
b
r
/
>
a
t
o
r
g
.
s
p
r
i
n
g
f
r
a
m
e
w
o
r
k
.
w
e
b
.
s
e
r
v
l
e
t
.
c
o
n
f
i
g
.
a
n
n
o
t
a
t
i
o
n
.
D
e
l
e
g
a
t
i
n
g
W
e
b
M
v
c
C
o
n
f
i
g
u
r
a
t
i
o
n
1.getObject(AbstractBeanFactory.java:305)<br /> at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)<br /> at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301)<br /> at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)<br /> at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)<br /> at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:834)<br /> at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537)<br /> at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:125)<br /> at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:60)<br /> at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:109)<br /> at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:261)<br /> at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:98)<br /> at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:116)<br /> ... 24 more<br />Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method 'defaultServletHandlerMapping' threw exception; nested exception is java.lang.IllegalArgumentException: A ServletContext is required to configure default servlet handling<br /> at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)<br /> at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)<br /> ... 41 more<br />Caused by: java.lang.IllegalArgumentException: A ServletContext is required to configure default servlet handling<br /> at org.springframework.util.Assert.notNull(Assert.java:115)<br /> at org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer.<init>(DefaultServletHandlerConfigurer.java:53)<br /> at org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport.defaultServletHandlerMapping(WebMvcConfigurationSupport.java:450)<br /> at org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration
1.getObject(AbstractBeanFactory.java:305)<br/>atorg.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)<br/>atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301)<br/>atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)<br/>atorg.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)<br/>atorg.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:834)<br/>atorg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537)<br/>atorg.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:125)<br/>atorg.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:60)<br/>atorg.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:109)<br/>atorg.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:261)<br/>atorg.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:98)<br/>atorg.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:116)<br/>...24more<br/>Causedby:org.springframework.beans.BeanInstantiationException:Failedtoinstantiate[org.springframework.web.servlet.HandlerMapping]:Factorymethod′defaultServletHandlerMapping′threwexception;nestedexceptionisjava.lang.IllegalArgumentException:AServletContextisrequiredtoconfiguredefaultservlethandling<br/>atorg.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)<br/>atorg.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)<br/>...41more<br/>Causedby:java.lang.IllegalArgumentException:AServletContextisrequiredtoconfiguredefaultservlethandling<br/>atorg.springframework.util.Assert.notNull(Assert.java:115)<br/>atorg.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer.<init>(DefaultServletHandlerConfigurer.java:53)<br/>atorg.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport.defaultServletHandlerMapping(WebMvcConfigurationSupport.java:450)<br/>atorg.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration
E
n
h
a
n
c
e
r
B
y
S
p
r
i
n
g
C
G
L
I
B
EnhancerBySpringCGLIB
EnhancerBySpringCGLIB
87050
d
b
a
.
C
G
L
I
B
87050dba.CGLIB
87050dba.CGLIBdefaultServletHandlerMapping
27
(
<
g
e
n
e
r
a
t
e
d
>
)
<
b
r
/
>
a
t
o
r
g
.
s
p
r
i
n
g
f
r
a
m
e
w
o
r
k
.
w
e
b
.
s
e
r
v
l
e
t
.
c
o
n
f
i
g
.
a
n
n
o
t
a
t
i
o
n
.
D
e
l
e
g
a
t
i
n
g
W
e
b
M
v
c
C
o
n
f
i
g
u
r
a
t
i
o
n
27(<generated>)<br /> at org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration
27(<generated>)<br/>atorg.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration
E
n
h
a
n
c
e
r
B
y
S
p
r
i
n
g
C
G
L
I
B
EnhancerBySpringCGLIB
EnhancerBySpringCGLIB
87050
d
b
a
87050dba
87050dba
F
a
s
t
C
l
a
s
s
B
y
S
p
r
i
n
g
C
G
L
I
B
FastClassBySpringCGLIB
FastClassBySpringCGLIB
120
f
7
a
5
f
.
i
n
v
o
k
e
(
<
g
e
n
e
r
a
t
e
d
>
)
<
b
r
/
>
a
t
o
r
g
.
s
p
r
i
n
g
f
r
a
m
e
w
o
r
k
.
c
g
l
i
b
.
p
r
o
x
y
.
M
e
t
h
o
d
P
r
o
x
y
.
i
n
v
o
k
e
S
u
p
e
r
(
M
e
t
h
o
d
P
r
o
x
y
.
j
a
v
a
:
228
)
<
b
r
/
>
a
t
o
r
g
.
s
p
r
i
n
g
f
r
a
m
e
w
o
r
k
.
c
o
n
t
e
x
t
.
a
n
n
o
t
a
t
i
o
n
.
C
o
n
f
i
g
u
r
a
t
i
o
n
C
l
a
s
s
E
n
h
a
n
c
e
r
120f7a5f.invoke(<generated>)<br /> at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)<br /> at org.springframework.context.annotation.ConfigurationClassEnhancer
120f7a5f.invoke(<generated>)<br/>atorg.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)<br/>atorg.springframework.context.annotation.ConfigurationClassEnhancerBeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:318)
at org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration
E
n
h
a
n
c
e
r
B
y
S
p
r
i
n
g
C
G
L
I
B
EnhancerBySpringCGLIB
EnhancerBySpringCGLIB87050dba.defaultServletHandlerMapping()
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
… 42 more
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:117)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:228)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:217)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:276)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:278)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:236)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:87)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner
2.
e
v
a
l
u
a
t
e
(
P
a
r
e
n
t
R
u
n
n
e
r
.
j
a
v
a
:
229
)
<
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
4.
s
t
a
t
e
m
e
n
t
s
.
R
u
n
B
e
f
o
r
e
T
e
s
t
C
l
a
s
s
C
a
l
l
b
a
c
k
s
.
e
v
a
l
u
a
t
e
(
R
u
n
B
e
f
o
r
e
T
e
s
t
C
l
a
s
s
C
a
l
l
b
a
c
k
s
.
j
a
v
a
:
61
)
<
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
4.
s
t
a
t
e
m
e
n
t
s
.
R
u
n
A
f
t
e
r
T
e
s
t
C
l
a
s
s
C
a
l
l
b
a
c
k
s
.
e
v
a
l
u
a
t
e
(
R
u
n
A
f
t
e
r
T
e
s
t
C
l
a
s
s
C
a
l
l
b
a
c
k
s
.
j
a
v
a
:
70
)
<
b
r
/
>
a
t
o
r
g
.
j
u
n
i
t
.
r
u
n
n
e
r
s
.
P
a
r
e
n
t
R
u
n
n
e
r
.
r
u
n
(
P
a
r
e
n
t
R
u
n
n
e
r
.
j
a
v
a
:
309
)
<
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
4.
S
p
r
i
n
g
J
U
n
i
t
4
C
l
a
s
s
R
u
n
n
e
r
.
r
u
n
(
S
p
r
i
n
g
J
U
n
i
t
4
C
l
a
s
s
R
u
n
n
e
r
.
j
a
v
a
:
180
)
<
b
r
/
>
a
t
o
r
g
.
j
u
n
i
t
.
r
u
n
n
e
r
.
J
U
n
i
t
C
o
r
e
.
r
u
n
(
J
U
n
i
t
C
o
r
e
.
j
a
v
a
:
160
)
<
b
r
/
>
a
t
c
o
m
.
i
n
t
e
l
l
i
j
.
j
u
n
i
t
4.
J
U
n
i
t
4
I
d
e
a
T
e
s
t
R
u
n
n
e
r
.
s
t
a
r
t
R
u
n
n
e
r
W
i
t
h
A
r
g
s
(
J
U
n
i
t
4
I
d
e
a
T
e
s
t
R
u
n
n
e
r
.
j
a
v
a
:
68
)
<
b
r
/
>
a
t
c
o
m
.
i
n
t
e
l
l
i
j
.
r
t
.
e
x
e
c
u
t
i
o
n
.
j
u
n
i
t
.
I
d
e
a
T
e
s
t
R
u
n
n
e
r
2.evaluate(ParentRunner.java:229)<br /> at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)<br /> at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)<br /> at org.junit.runners.ParentRunner.run(ParentRunner.java:309)<br /> at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)<br /> at org.junit.runner.JUnitCore.run(JUnitCore.java:160)<br /> at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)<br /> at com.intellij.rt.execution.junit.IdeaTestRunner
2.evaluate(ParentRunner.java:229)<br/>atorg.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)<br/>atorg.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)<br/>atorg.junit.runners.ParentRunner.run(ParentRunner.java:309)<br/>atorg.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)<br/>atorg.junit.runner.JUnitCore.run(JUnitCore.java:160)<br/>atcom.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)<br/>atcom.intellij.rt.execution.junit.IdeaTestRunnerRepeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘defaultServletHandlerMapping’ defined in class path resource [org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method ‘defaultServletHandlerMapping’ threw exception; nested exception is java.lang.IllegalArgumentException: A ServletContext is required to configure default servlet handling
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory
1.
g
e
t
O
b
j
e
c
t
(
A
b
s
t
r
a
c
t
B
e
a
n
F
a
c
t
o
r
y
.
j
a
v
a
:
305
)
<
b
r
/
>
a
t
o
r
g
.
s
p
r
i
n
g
f
r
a
m
e
w
o
r
k
.
b
e
a
n
s
.
f
a
c
t
o
r
y
.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
w
o
r
k
.
w
e
b
.
s
e
r
v
l
e
t
.
c
o
n
f
i
g
.
a
n
n
o
t
a
t
i
o
n
.
D
e
l
e
g
a
t
i
n
g
W
e
b
M
v
c
C
o
n
f
i
g
u
r
a
t
i
o
n
1.getObject(AbstractBeanFactory.java:305)<br /> at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)<br /> at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301)<br /> at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)<br /> at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)<br /> at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:834)<br /> at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537)<br /> at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:125)<br /> at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:60)<br /> at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:109)<br /> at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:261)<br /> at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:98)<br /> at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:116)<br /> ... 24 more<br />Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method 'defaultServletHandlerMapping' threw exception; nested exception is java.lang.IllegalArgumentException: A ServletContext is required to configure default servlet handling<br /> at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)<br /> at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)<br /> ... 41 more<br />Caused by: java.lang.IllegalArgumentException: A ServletContext is required to configure default servlet handling<br /> at org.springframework.util.Assert.notNull(Assert.java:115)<br /> at org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer.<init>(DefaultServletHandlerConfigurer.java:53)<br /> at org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport.defaultServletHandlerMapping(WebMvcConfigurationSupport.java:450)<br /> at org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration
1.getObject(AbstractBeanFactory.java:305)<br/>atorg.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)<br/>atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301)<br/>atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)<br/>atorg.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)<br/>atorg.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:834)<br/>atorg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537)<br/>atorg.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:125)<br/>atorg.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:60)<br/>atorg.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:109)<br/>atorg.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:261)<br/>atorg.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:98)<br/>atorg.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:116)<br/>...24more<br/>Causedby:org.springframework.beans.BeanInstantiationException:Failedtoinstantiate[org.springframework.web.servlet.HandlerMapping]:Factorymethod′defaultServletHandlerMapping′threwexception;nestedexceptionisjava.lang.IllegalArgumentException:AServletContextisrequiredtoconfiguredefaultservlethandling<br/>atorg.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)<br/>atorg.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)<br/>...41more<br/>Causedby:java.lang.IllegalArgumentException:AServletContextisrequiredtoconfiguredefaultservlethandling<br/>atorg.springframework.util.Assert.notNull(Assert.java:115)<br/>atorg.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer.<init>(DefaultServletHandlerConfigurer.java:53)<br/>atorg.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport.defaultServletHandlerMapping(WebMvcConfigurationSupport.java:450)<br/>atorg.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration
E
n
h
a
n
c
e
r
B
y
S
p
r
i
n
g
C
G
L
I
B
EnhancerBySpringCGLIB
EnhancerBySpringCGLIB
87050
d
b
a
.
C
G
L
I
B
87050dba.CGLIB
87050dba.CGLIBdefaultServletHandlerMapping
27
(
<
g
e
n
e
r
a
t
e
d
>
)
<
b
r
/
>
a
t
o
r
g
.
s
p
r
i
n
g
f
r
a
m
e
w
o
r
k
.
w
e
b
.
s
e
r
v
l
e
t
.
c
o
n
f
i
g
.
a
n
n
o
t
a
t
i
o
n
.
D
e
l
e
g
a
t
i
n
g
W
e
b
M
v
c
C
o
n
f
i
g
u
r
a
t
i
o
n
27(<generated>)<br /> at org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration
27(<generated>)<br/>atorg.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration
E
n
h
a
n
c
e
r
B
y
S
p
r
i
n
g
C
G
L
I
B
EnhancerBySpringCGLIB
EnhancerBySpringCGLIB
87050
d
b
a
87050dba
87050dba
F
a
s
t
C
l
a
s
s
B
y
S
p
r
i
n
g
C
G
L
I
B
FastClassBySpringCGLIB
FastClassBySpringCGLIB
120
f
7
a
5
f
.
i
n
v
o
k
e
(
<
g
e
n
e
r
a
t
e
d
>
)
<
b
r
/
>
a
t
o
r
g
.
s
p
r
i
n
g
f
r
a
m
e
w
o
r
k
.
c
g
l
i
b
.
p
r
o
x
y
.
M
e
t
h
o
d
P
r
o
x
y
.
i
n
v
o
k
e
S
u
p
e
r
(
M
e
t
h
o
d
P
r
o
x
y
.
j
a
v
a
:
228
)
<
b
r
/
>
a
t
o
r
g
.
s
p
r
i
n
g
f
r
a
m
e
w
o
r
k
.
c
o
n
t
e
x
t
.
a
n
n
o
t
a
t
i
o
n
.
C
o
n
f
i
g
u
r
a
t
i
o
n
C
l
a
s
s
E
n
h
a
n
c
e
r
120f7a5f.invoke(<generated>)<br /> at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)<br /> at org.springframework.context.annotation.ConfigurationClassEnhancer
120f7a5f.invoke(<generated>)<br/>atorg.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)<br/>atorg.springframework.context.annotation.ConfigurationClassEnhancerBeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:318)
at org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration
E
n
h
a
n
c
e
r
B
y
S
p
r
i
n
g
C
G
L
I
B
EnhancerBySpringCGLIB
EnhancerBySpringCGLIB87050dba.defaultServletHandlerMapping()
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
… 42 more
2 解决办法
主要是查看caused by中间的内容:
Caused by: java.lang.IllegalArgumentException: A ServletContext is required to configure default servlet handling 便是问题所在
由解决方案可知,我们需要在测试类中添加一个@WebAppConfiguration注解。可以添加在具体的测试类中,也可以添加在测试基类中。
注解maven依赖,我的版本是4.2.1.RELEASE
配置spring
在测试类中引入注解
再次运行即可成功进行单元测试。
3 总结
单元测试出错,首先检查Caused by,然后检查配置文件以及代码是否有问题。