ImportSelector介面

巴黎↓一整天發表於2020-11-17

AppInletConfig.class

public class AppInletConfig implements ImportSelector {
    @Override
    public String[] selectImports(AnnotationMetadata importingClassMetadata) {
        return new String[]{ SwaggerConfig.class.getName()};  // 需要載入的類
    }
}

啟動類 @Import(AppInletConfig.class)

@SpringBootApplication
@Import(AppInletConfig.class)
@EnableDubbo
@EnableApolloConfig
@ComponentScan("*")
public class AssetGateWayApiApplication {

    /**
     * @param args a
     */
    public static void main(String[] args) {
        SpringApplication.run(AssetGateWayApiApplication.class, args);
    }

}```

相關文章