feign 改为 dubbo

This commit is contained in:
GYJ
2025-02-11 14:27:51 +08:00
parent 30b9cef27f
commit 009cd44653
19 changed files with 194 additions and 106 deletions

View File

@@ -1,10 +1,10 @@
package com.czg;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
@@ -12,9 +12,9 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
*/
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
@EnableTransactionManagement
@MapperScan("com.czg.service.account.mapper")
@EnableDubbo
public class AccountApplication {
public static void main(String[] args) {
SpringApplication.run(AccountApplication.class, args);

View File

@@ -1,9 +1,9 @@
package com.czg.controller;
import com.czg.service.account.feign.FeignSystemService;
import com.czg.service.RedisService;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import com.alibaba.fastjson2.JSONObject;
import com.czg.system.dto.SysParamsDTO;
import com.czg.system.service.SysParamsService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -14,18 +14,13 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/feign")
public class FeignController {
@Resource
private FeignSystemService feignSystemService;
@Autowired
private RedisService redisService;
@DubboReference
private SysParamsService sysParamsService;
@RequestMapping("/test")
public String test() {
String string = feignSystemService.testCall("sssss");
System.out.println(string);
redisService.set("sssss", string);
return "test";
SysParamsDTO test = sysParamsService.getParamsByCode2("test");
return JSONObject.toJSONString(test);
}
}