我正在将旧的Spring MVC应用程序从基于xml的更新为基于注释的配置。我不确定如何在@ComponentScan批注中添加“名称生成器”。
这是我所拥有的:
@Configuration
@EnableAsync
@EnableScheduling
@EnableAspectJAutoProxy
@ComponentScan({"com.styxrbad", "com.styxrbad.common"})
@Import({DatabaseConfiguration.class, WebMvcConfiguration.class})
public class SpringConfiguration
{
}
我需要包括实现的BeanNameGenerator,以替换注释中xml中的“ name-generator”字段。我是Spring的新手,我不了解语法,也无法在研究中找到任何示例。我怎样才能做到这一点?
最佳答案
@ComponentScan
具有属性nameGenerator
。
对您来说足够了吗?
更新:
@ComponentScan(value = {"com.styxrbad", "com.styxrbad.common"}, nameGenerator = MyBeanNameGenerator.class)