Beanはspringbootによってロードされている場合はどのように確認することができます

スティーブン・スマート:

私はSpringbootを使用して、いくつかのGrpc豆を実行しようとしていますし、私が確認したすべてを見るspringbootのアプリケーションの負荷です。どこで豆がロードされたことの確認を見つけることができますか?それは、この表示されますようにspringbootを起動する方法はありますか?

Jaspreetジョリー:

コードの下にその容器の中に春のアプリケーションによってロードされているすべてのBeanをログに記録します。 -

@SpringBootApplication
public class Application implements CommandLineRunner {

    @Autowired
    private ApplicationContext appContext;

    public static void main(String[] args) throws Exception {
        SpringApplication.run(Application.class, args);
    }

    @Override
    public void run(String... args) throws Exception {

        String[] beans = appContext.getBeanDefinitionNames();
        Arrays.sort(beans);
        for (String bean : beans) {
            System.out.println(bean);
        }

    }
}

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=337282&siteId=1