RestTemplateFactory.java 文件源码

java
阅读 25 收藏 0 点赞 0 评论 0

项目:Persephone 作者:
/**
 * register specific RestTemplate in Spring Application Context if needed
 */
private Consumer<Application> createRestTemplateBasicAuth(ConfigurableListableBeanFactory registry) {
    return app -> {

        // Create rest template instance
        RestTemplate restTemplateBasicAuth = defaultRestTemplateConfig.restTemplate(requestFactory, Arrays.asList(defaultRestTemplateConfig.getDefaultAcceptHeader(), MediaType.ALL));

        // Configure it with BASIC auth
        restTemplateBasicAuth.getInterceptors().add(new BasicAuthorizationInterceptor(app.getActuatorUsername(), app.getActuatorPassword()));

        LOGGER.info("Registered RestTemplate with BASIC auth for application with id {}", app.getId());

        // Add bean in Spring application context
        registry.registerSingleton(getRestTemplateBeanName(app), restTemplateBasicAuth);
    };
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号