在< context:component-scan>中包含子包的语法是什么 [英] What syntax for including sub-packages in <context:component-scan>?

查看:102
本文介绍了在< context:component-scan>中包含子包的语法是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Spring,我有很长的子包列表,我是否必须在< context:component-scan> 标记中逐一指定它们?

I am using Spring and I have a long list of subpackages, do I have to specify them one by one in the <context:component-scan> tag?

<context:component-scan base-package="com.fooapp.mainpackage, 
com.fooapp.mainpackage.subpackage1, 
com.fooapp.mainpackage.subpackage2, 
com.fooapp.mainpackage.subpackage3" />


推荐答案

组件扫描支持包层次结构,所以这应该工作:

Component-scanning supports package hierarchies, so this should work:

<context:component-scan base-package="com.fooapp.mainpackage"/>

这样可以轻松快捷地验证自己 - 你试过吗?

This is easy and quicker to verify for yourself - did you try it?

这篇关于在&lt; context:component-scan&gt;中包含子包的语法是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆