排除过滤器的同时,JUnit的测试中@Component类? [英] Exclude-filter for a @Component class while JUnit testing?
本文介绍了排除过滤器的同时,JUnit的测试中@Component类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是可以排除 @Component
注解的类?
我想从JUnit的测试排除一个特殊的类。
i would like to exclude a special class from JUnit testing.
我的项目有一个类 xEventHandler
与 @Component
注释,我不想春季使用这个类的junit时测试。
my project has a class xEventHandler
annotated with @Component
and i dont want spring to use this class while junit testing.
我ApplicationTestContext.xml看起来是这样的:
my ApplicationTestContext.xml looks like this:
<context:component-scan base-package="com.company">
...
<context:exclude-filter expression="com\.company\.xyz\.xEventHandler.java " type="regex"/>
...
</context:component-scan>
然而,该类被进入,因为 @Component
注释(如工程,当我删除 @Component
从类)。
however, the class gets entered because of the @Component
annotation(e.g. works, when i delete the @Component
from that class).
如何解决呢?
推荐答案
我想这应该仅仅是:
<context:exclude-filter expression="com\.company\.xyz\.xEventHandler" type="regex"/>
这篇关于排除过滤器的同时,JUnit的测试中@Component类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文