Spring boot injection into two-party package bean

Spring boot project has introduced a two-party package. Every time a class An in the two-party package is used, new A (), An itself is a normal class in the two-party package. There is no @ Component and other notes related to spring. If you want to annotate bean, in the spring boot project, how to inject it? please use A

as follows.
@Componet
private A a;

uses the following comments, adding @ ComponentScan to the startup app class, adding the path to the third-party package or reporting an error

@Configurable
public class Util{

@Bean
public A getA(){
    return new A();
}
}
Mar.22,2021

use the annotations Bean and Configuration

@Configuration
public class YourConfig{
    @Bean
    public A a(){
        return new A();
    }
}
Menu