0
我的主要入门级与“无消息”从Spring应用程序
package com.project.cloud;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@EnableDiscoveryClient
@SpringBootApplication
public class HelloworldClientApplication {
public static void main(String[] args) {
SpringApplication.run(HelloworldClientApplication.class, args);
}
}
我的资源文件
package com.project.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
/**
*
* @author Wasp Networks
*/
@RestController
@RequestMapping("/rest/client/helloworld")
public class HelloResources {
@Autowired
private RestTemplate restTemplate;
@GetMapping
public String Entry(){
String url = "http://helloworld-server/rest/server/helloworld";
return restTemplate.getForObject(url, String.class);
}
@RequestMapping("/")
public String Main(){
return "Helloworld client!.";
}
}
我的配置类
package com.project.configuration;
/**
*
* @author Wasp Networks
*/
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
@Configuration
public class Configure {
@LoadBalanced
@Bean
public RestTemplate restTemplate(){
return new RestTemplate();
}
}
如果你的春天代码结构错误页面是这样的,你尝试运行该应用程序,不要惊讶,以获得错误的Web控制台。
对不起家伙对我的英语不好....