【问题标题】:Name of a bean which is annotated with @Named without specifying any string in @Named?使用@Named 注释但未在@Named 中指定任何字符串的bean 的名称?
【发布时间】:2013-02-26 05:30:54
【问题描述】:

假设我有一个使用 @Named 注解注入的 bean。例如,

@Named
public class MyBean {}

运行时 bean 的名称是什么?我搜索了网络,但找不到答案。也不知道怎么调试才能找到名字。

【问题讨论】:

    标签: spring dependency-injection annotations


    【解决方案1】:

    bean 的名称将是类名。

    示例:类 CustomerService 将被命名为 customerService

    【讨论】:

    • 好的。我是这么想的,但想确认一下。那么,上面的 bean 会被命名为“MyBean”还是“myBean”或“my-bean”?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多