Client side is added
This commit is contained in:
35
Client/src/main/java/hello/Application.java
Normal file
35
Client/src/main/java/hello/Application.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package hello;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@SpringBootApplication
|
||||
public class Application {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(Application.class);
|
||||
|
||||
public static void main(String args[]) {
|
||||
SpringApplication.run(Application.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RestTemplate restTemplate(RestTemplateBuilder builder) {
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CommandLineRunner run(RestTemplate restTemplate) throws Exception {
|
||||
return args -> {
|
||||
Message message = restTemplate.getForObject(
|
||||
"http://localhost:8080/greeting?name=Ceren", Message.class);
|
||||
log.info(message.toString());
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
37
Client/src/main/java/hello/Message.java
Normal file
37
Client/src/main/java/hello/Message.java
Normal file
@@ -0,0 +1,37 @@
|
||||
package hello;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class Message {
|
||||
|
||||
private long id;
|
||||
private String content;
|
||||
|
||||
public Message() {
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Message{" +
|
||||
"id='" + id + '\'' +
|
||||
", content=" + content +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user