2013-08-20 16:45:06 +08:00
|
|
|
package org.test
|
|
|
|
|
2021-01-21 02:18:00 +08:00
|
|
|
import org.springframework.web.client.RestTemplate;
|
2013-08-20 16:45:06 +08:00
|
|
|
|
|
|
|
@Controller
|
|
|
|
class Example implements CommandLineRunner {
|
|
|
|
|
2014-04-24 03:10:30 +08:00
|
|
|
@Autowired
|
2021-01-01 22:15:38 +08:00
|
|
|
ApplicationContext context
|
2014-04-24 03:10:30 +08:00
|
|
|
|
2013-08-20 16:45:06 +08:00
|
|
|
@RequestMapping("/")
|
|
|
|
@ResponseBody
|
|
|
|
public String helloWorld() {
|
|
|
|
return "World!"
|
|
|
|
}
|
|
|
|
|
|
|
|
void run(String... args) {
|
2021-01-01 22:15:38 +08:00
|
|
|
def port = context.webServer.port
|
2021-01-21 02:18:00 +08:00
|
|
|
def world = new RestTemplate().getForObject("http://localhost:" + port + "/", String.class);
|
2013-08-20 16:45:06 +08:00
|
|
|
print "Hello " + world
|
|
|
|
}
|
2014-07-29 04:31:22 +08:00
|
|
|
|
2013-08-20 16:45:06 +08:00
|
|
|
}
|