Problem Record --springbean injection results in a null pointer exception failure

Today encountered problems such as the title of the work, specially after the record about solving
springboot class will start scanning the current package and the package, and that bean I was not there, so the injection failure, solution is to take the initiative by adding annotations @Bean to spring management

@Configuration
public class AuditConfiguration {

    @Bean(name = "printLogHandler")
    public PrintLogHandler printLogHandler() {
        return new PrintLogHandler();
    }


    @Bean (name = "rocketMQHandler")
    public RocketMQHandler rocketMQHandler() {
        return new RocketMQHandler();
    }
}
Published 25 original articles · won praise 22 · views 3624

Guess you like

Origin blog.csdn.net/weixin_42443419/article/details/104419131