1
I have a big problem that in my Genericservice I use an @Autowired on an Httpservletrequest (Even not knowing the utility, because, I do not know the architecture so well), and needed to use unit test for test battery in my services, however, when I inject the bean into my test spring cannot inject this Httpservletrequest as it could before in the container.
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'br.com.field.service.TalhaoService':
Injection of autowired dependencies failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Could not autowire
field: private javax.servlet.http.HttpServletRequest
br.com.visioncore.service.GenericServiceImpl.httpRequest; nested exception
is org.springframework.beans.factory.NoSuchBeanDefinitionException: No
qualifying bean of type [javax.servlet.http.HttpServletRequest] found for
dependency: expected at least 1 bean which qualifies as autowire candidate
for this dependency. Dependency annotations:
{@org.springframework.beans.factory.annotation.Autowired(required=true)}
Does anyone know how to test this? I’ve managed to get my context settings inside Test and I just need it now.
Thanks for the lesson, I get a clearer view now.
– user14069