@Autowired annotations are injected as NULL in the non-controller
1. Configuration files (packages where class files are located)
<base-package= "Net.nblh.utils.common"/>
2. class files
About @postconstruct: The method modified by @postconstruct will run when the server loads the servlet and will only be called once by the server, similar to the Serclet Inti () method. Methods that are modified by @postconstruct will run before the Init () method after the constructor.
@Component//declaration as spring component Public classGetspeechrecognitioninfo {@AutowiredPrivateIconfdayservice Confdayservice; //Static first-order current class Public StaticGetspeechrecognitioninfo Getspeechrecognitioninfo; //annotation @postconstruct, so that the method is executed by the spring container after the bean is initialized@PostConstruct Public voidinit () {Getspeechrecognitioninfo= This; } Public Static voidsyncdocument (String topicid) {List<TopicFile> fileList = getSpeechRecognitionInfo.confdayService.getConfFileByIssue (TopicID);//List of topic materials }}
java-Normal class file @autowired automatically injected as null