尽头歌词若依Api调⽤【remoteHrService】若依微服务间Api调⽤
照着若依的写;
注意的是【FeignClient的value值】||【请求的Mapping】||【spring.factories⾥的配置】⽂件⽬录
RemoteHrService的修改
RemoteHrFallbackFactory 的修改package
男歌手
;import
ServiceNameConstants ;import
R ;import
RemoteHrFallbackFactory ;import
FeignClient ;import GetMapping ;
/**
没有婚姻线星字* @Author: 郑兴华
蘑菇头发型男
* @CreateTime: 2021-12-04 10:08
* @Description:
*/
//value 是要调⽤模块的名称,⼀定不要写错
@FeignClient(contextId = "remoteHrService", value = ServiceNameConstants .SYSTEM_HR , fallbackFactory = RemoteHrFallbackFactory .class )public interface RemoteHrService {
//请求的地址不要搞错了,不要多写也不要少些
//⽅法的话直接去抄之前写的
@GetMapping("/hrResume/updateFileId")
R updateFileId ();
}
package
;import
R ;import
RemoteHrService ;import
FallbackFactory ;
import
Logger ;import LoggerFactory ;/**
* @Author: 郑兴华
* @CreateTime: 2021-12-04 10:08
* @Description:
*/
public class RemoteHrFallbackFactory implements FallbackFactory <RemoteHrService > {
private static final Logger log = LoggerFactory .getLogger (RemoteHrFallbackFactory .class );
@Override
public RemoteHrService create (Throwable throwable ) {
log .error ("⽇志服务调⽤失败:{}", throwable .getMessage ());
return new RemoteHrService () {
@Override
public R updateFileId () {
//可以写调⽤和细节
return null ;
}
};
}
}
⼀定加上⾃⼰的FallbackFactory,不然失败;spring.factories 测试测试结果
是能正常执⾏的and 任务完成org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.ruoyi.system.api.factory.RemoteUrFallbackFactory,\ com.ruoyi.system.api.factory.RemoteHrFallbackFactory,\ com.ruoyi.system.api.factory.RemoteLogFallbackFactory @RestController
泰山神@RequestMapping("/job")
public class SysJobController extends BaController
{
语文的拼音
降妖宝杖@Autowired
RemoteHrService remoteHrService ;
@GetMapping("/test")
public AjaxResult test ()
{
return AjaxResult .success (remoteHrService .updateFileId ()); }