<dependency>
<groupId>org
.springframework.cloud</groupId>
<artifactId>spring
‐
cloud
‐
starter
‐
openfeign</artifactId>
</dependency>
<dependency>
<groupId>com.netflix.feign</groupId>
<artifactId>feign
‐
okhttp</artifactId>
</dependency>
@FeignClient(value
= XcServiceList.XC_SERVICE_MANAGE_CMS)
public interface CmsPageClient {
@GetMapping(
"
/cms/page/get/{id}
"
)
public CmsPage findById(@PathVariable(
"
id
"
) String id);
}
@RunWith(SpringRunner.class)
@SpringBootTest
public class FeignTest {
@Autowired
CmsPageClient cmsPageClient;
@Test
public void testFeign() {
//通过服务id调用cms的查询页面接口
CmsPage cmsPage
=
cmsPageClient.findById(
"
5a754adf6abb500ad05688d9
"
);
System.out.
println(cmsPage);
}
}
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |