我想将配置文件名称设置为整个程序包,但我不知道如何。如果在哪里不是简单的方法,那么我必须用@Profile
注释标记包和子包中的每个类。
<context:component-scan/>
标签不支持这样的属性,profile
所以我不知道。
您可以将个人资料设置为:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"
profile="your-profile">
<context:component-scan base-package="your.package" />
</beans>
@Configuration
Java配置类@Configuration
@Profile("your-profile")
@Componentscan("your.package")
class AppConfig {
}
在它们的每一个中,您都可以对特定的软件包使用组件扫描。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句