Setting @Autowired(required=false) globally during spring-boot test -


i can't classic xml config

<bean class="org.springframework.beans.factory.annotation.autowiredannotationbeanpostprocessor">         <property name="requiredparametervalue" value="false" />     </bean> 

to work in spring-boot test. i've tried equivalent java style

@bean     public autowiredannotationbeanpostprocessor annotation() {         autowiredannotationbeanpostprocessor annotation = new autowiredannotationbeanpostprocessor();         annotation.setrequiredparametervalue(false);         return annotation; } 

also no avail.

i'm trying find solution cherry-pick beans need unit testing.

here's code i'm using in test itself:

@rollback @springapplicationconfiguration({packageservicetestconfiguration.class, databaseconfiguration.class, mybatisconfiguration.class}) @activeprofiles("test") public class packageservicetest extends abstracttransactionaltestngspringcontexttests {...} 

the content of packageservicetestconfiguration.class (database , mybatis config part of apps need perform test

@configuration  @componentscan(basepackages = "com.project.api.permission.service",     includefilters = @componentscan.filter(service.class)) @importresource("classpath:testcontext.xml") public class packageservicetestconfiguration {} 

testcontext.xml contains test fixtures , failing autowiredannotationbeanpostprocessor configuration

thanks @componentscan can filter down package component configure, still not convenient xml can define each of bean need 1 liner.

i still need make @autowired component not required globally test, , can't find way this.


Comments

Popular posts from this blog

wireshark - USB mapping with python -

c++ - nodejs socket.io closes connection before upgrading to websocket -

Deploying Qt Application on Android is really slow? -