如何将名称生成器添加到上下文中:注释表单中的组件扫描?

时间:2014-03-21 16:07:17

标签: java spring spring-mvc spring-annotations

我正在努力将基于xml的旧的Spring MVC应用程序更新为基于注释的配置。我不确定如何在@ComponentScan注释中添加“name-generator”。

这就是我所拥有的:

@Configuration
@EnableAsync
@EnableScheduling
@EnableAspectJAutoProxy
@ComponentScan({"com.styxrbad", "com.styxrbad.common"})
@Import({DatabaseConfiguration.class, WebMvcConfiguration.class})
public class SpringConfiguration
{

}

我需要包含我实现的BeanNameGenerator来替换注释中xml的“name-generator”字段。我是Spring的新手,我不知道语法,也不能在我的研究中找到任何例子。 我该怎么做?

1 个答案:

答案 0 :(得分:2)

@ComponentScan有一个属性nameGenerator

对你来说够了吗?

<强>更新

@ComponentScan(value = {"com.styxrbad", "com.styxrbad.common"}, nameGenerator = MyBeanNameGenerator.class)