据我所知, context:component-scan需要指定base-package属性。 如何配置它来扫描类路径中的所有类?
As far as I know, context:component-scan requires the base-package attribute to be specified. How do I configure this to scan all the classes in the classpath?
最满意答案
你没有。 那将是一场噩梦。
例如,这意味着将加载所有lib的所有类,将所有可选依赖项转换为必需的依赖项。 即,如果在类路径上有spring-orm.jar,则需要在类路径上使用所有Hibernate,JPA,JDO和MyBatis。
包是设计应用程序的重要部分。 如果您没有一个根软件包,则可以扫描多个。 但是,如果您无法识别所需的所有根软件包,那么您就会遇到严重的组织问题,并且您不应期望Spring会为您修复它们。
You don't. That would be a nightmare.
For example, this would mean that all classes of all your libs are loaded, turning all your optional dependencies into required ones. I.e., if you had spring-orm.jar on the class path, this would require you to have all of Hibernate, JPA, JDO and MyBatis on the class path.
Packages are an important part of designing an application. If you don't have one root package, you can scan several. But if it's not possible for you to identify all root packages you need, then you have serious organizational problems, and you shouldn't expect Spring to fix them for you.
发布者:admin,转转请注明出处:http://www.yc00.com/web/1690886889a455286.html
评论列表(0条)