我正在使用Spring,并且子包列表很长,是否必须在<context:component-scan>标记中一一指定?

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

最佳答案

组件扫描支持程序包层次结构,因此应该可以:

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

您可以轻松,快速地进行自我验证-您尝试过吗?

关于java - 在<context :component-scan>?中包括子包的语法是什么,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6807230/

10-10 08:45