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

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -