spring boot@autowired字段在@configuration类中注入null,但与@import一起使用

spring boot@autowired字段在@configuration类中注入null,但与@import一起使用,spring,configuration,null,spring-boot,autowired,Spring,Configuration,Null,Spring Boot,Autowired,根据参考,我在应用程序类上使用了@ComponentScan,在我的配置类上使用了@Configuration,在我的配置类中,我想通过使用@Autowired注释注入在其他配置类中定义的bean,但是当我运行应用程序时,这些字段的值为null,我尝试在应用程序上使用import,并从config类中删除@Configuration,一切正常 这是spring boot的错误还是我对@Configuration注释的用法有误解?您是否试图将其他配置类自动关联到应用程序类中? 在Spring创建应

根据参考,我在应用程序类上使用了
@ComponentScan
,在我的配置类上使用了
@Configuration
,在我的配置类中,我想通过使用
@Autowired
注释注入在其他配置类中定义的bean,但是当我运行应用程序时,这些字段的值为null,我尝试在应用程序上使用
import
,并从config类中删除
@Configuration
,一切正常


这是
spring boot
的错误还是我对
@Configuration
注释的用法有误解?

您是否试图将其他配置类自动关联到应用程序类中?
在Spring创建应用程序类的实例后,使用fresh方法和@PostConstruct使其自动调用

你能分享你的代码吗spring boot中没有bug。。。为很多人工作。。可能你的课程布局不对。。请分享您的布局或只是看一下示例。。