Merge pull request #575 from skoiloth/master
Autowiring the RestTemplate
This commit is contained in:
commit
6aef1b0104
|
@ -4,6 +4,8 @@ import org.springframework.boot.SpringApplication;
|
|||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.context.web.SpringBootServletInitializer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@SpringBootApplication
|
||||
public class SpringDemoApplication extends SpringBootServletInitializer {
|
||||
|
@ -16,4 +18,9 @@ public class SpringDemoApplication extends SpringBootServletInitializer {
|
|||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
|
||||
return application.sources(SpringDemoApplication.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RestTemplate getRestTemplate(){
|
||||
return new RestTemplate();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.io.IOException;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.IntegrationTest;
|
||||
import org.springframework.boot.test.SpringApplicationContextLoader;
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
@ -21,7 +22,8 @@ import org.springframework.web.client.RestTemplate;
|
|||
public class SpringIntegrationTest {
|
||||
protected static ResponseResults latestResponse = null;
|
||||
|
||||
protected RestTemplate restTemplate = null;
|
||||
@Autowired
|
||||
protected RestTemplate restTemplate;
|
||||
|
||||
protected void executeGet(String url) throws IOException {
|
||||
final Map<String, String> headers = new HashMap<>();
|
||||
|
|
Loading…
Reference in New Issue