Singleton and @Autowired returning NULL

后端 未结 4 545
难免孤独
难免孤独 2021-01-02 07:21

I have a repository manager that manages my repositories. I have the @Autowired to instantiate my properties, but they are always null. The beans are correctly configured

4条回答
  •  南笙
    南笙 (楼主)
    2021-01-02 07:51

    The reason this is happening is because of the static method Instance()

    you are creating the POJO outside of the spring context.

    you can fix this, by adding to your configuration, and then annotating RepositoryManager with @Configurable

提交回复
热议问题