Vijay Manohar
Vijay Manohar

Reputation: 503

Excluding @bean from ComponentScan

I have lot of beans declared in a single class

package com.example;
@Configuration
public class MainBeanClass{

@Override
@Bean("cachingSession")
@Lazy
public CqlSessionFactoryBean cassandraSession() {
/**/
}

@Bean
public String createStringBean(){
 System.out.println("createStringBean has been instantiated");
}

}

I wanted to exclude the this bean from loading for my testCases. In my test-context.xml

<context:component-scan base-package="com.example">
    <context:exclude-filter><!--Not able to exclude the bean cachingSession -->
</context:component:scan>

is there any better way to exclude a bean on test-context.xml

Upvotes: 1

Views: 227

Answers (0)

Related Questions