在需要使用导入包中的没有自动配置到springBean的情况下,可以这样。
创建一个ConfigBean类
@Configuration
//@Configuration相当于spring中的application.xml配置文件
public class ConfigBean{
@Bean
public RestTemplate getRestTemplate(){
return new RestTemplate();
}
}
这样在使用的时候就可以
@Autowired
private RestTemplate restTemplate;
拿过来使用了