您的位置:首页 > 编程语言 > Java开发

Spring 使用@ComponentScan扫描注解包

2016-05-05 15:03 453 查看
@Configuration
@ComponentScan(basePackages = "org.example", nameGenerator = MyNameGenerator.class)
public class AppConfig {
...
}

在xml中的写法如此:

<beans>
<context:component-scan base-package="org.example"
name-generator="org.example.MyNameGenerator" />
</beans>


@componentScan注解的方法如下图

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: