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);
}
}

View File

@@ -15,18 +15,19 @@ spring:
cloud:
nacos:
config:
bootstrap:
enabled: true
data-id: system-server
group: DEFAULT_GROUP
auto-refresh: true
server-addr: 101.37.12.135:8848
namespace: 237e1905-0a66-4375-9bb6-a51c3c034aca
file-extension: yaml
discovery:
server-addr: 101.37.12.135:8848
namespace: 237e1905-0a66-4375-9bb6-a51c3c034aca
dubbo:
application:
name: account-server
qos-port: 22221
qos-enable: true
registry:
address: nacos://101.37.12.135:8848 # Nacos 服务地址
group: server
namespace: 237e1905-0a66-4375-9bb6-a51c3c034aca
protocol:
port: 9101