在这里,我们只想从某个类路径中排除一个类,比方说
com.abc.projectA.service.orderService.sectionA.orderService.class
但是,有另一个具有相同名称但在不同类路径中的类
com.abc.projectA.service.orderService.sectionB.orderService.class
这样只有按类名称的文件管理器才能生效.
但我尝试了以下方法:
<context:component-scan base-package="com.abc">
<!--other filters-->
<!--.......-->
<context:exclude-filter expression="projectA\.service\.orderService\.sectionA\.orderService" type="regex" />
</context:component-scan>
Run Code Online (Sandbox Code Playgroud)
它不起作用.所以我打赌<context:exclude-filter>唯一有效的包级别但不是特定的类?如果是这样,如何从bean注入中排除一个类,以便我们可以选择类来连接相同的类名?
提前致谢.
Bij*_*men 15
不,排除应该有效,你遇到的问题可能就是你假设正则表达式中的路径将被预先设置为不正确的基础包.所以只需指定完整的包
<context:component-scan base-package="com.abc">
<!--other filters-->
<!--.......-->
<context:exclude-filter expression="com\.abc\.projectA\.service\.orderService\.sectionA\.orderService" type="regex" />
</context:component-scan>
Run Code Online (Sandbox Code Playgroud)