nacos feign
This commit is contained in:
parent
26833efde5
commit
5d2533be35
|
|
@ -0,0 +1,25 @@
|
|||
package com.czg.controller;
|
||||
|
||||
import com.czg.feign.FeignSystemService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author GYJoker
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/feign")
|
||||
public class FeignController {
|
||||
|
||||
@Resource
|
||||
private FeignSystemService feignSystemService;
|
||||
|
||||
@RequestMapping("/test")
|
||||
public String test() {
|
||||
String string = feignSystemService.testCall("sssss");
|
||||
System.out.println(string);
|
||||
return "test";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,5 +1,11 @@
|
|||
|
||||
spring:
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://rm-bp1kn7h89nz62cno1ro.mysql.rds.aliyuncs.com:3306/czg_cashier?useUnicode=true&characterEncoding=utf-8
|
||||
username: cashier
|
||||
password: Cashier@1@
|
||||
|
||||
cloud:
|
||||
nacos:
|
||||
config:
|
||||
|
|
@ -15,3 +21,4 @@ spring:
|
|||
server-addr: 101.37.12.135:8848
|
||||
namespace: 237e1905-0a66-4375-9bb6-a51c3c034aca
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -40,43 +40,6 @@
|
|||
<groupId>org.apache.tomcat.embed</groupId>
|
||||
<artifactId>tomcat-embed-core</artifactId>
|
||||
</dependency>
|
||||
<!-- Spring Boot与nacos整合的核心依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
<version>2023.0.3.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 配置管理依赖,如果你需要配置管理功能 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
<version>2023.0.3.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||
<version>4.1.4</version>
|
||||
</dependency>
|
||||
|
||||
<!--openfeign依赖-->
|
||||
<!--start-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
<version>4.2.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
</dependency>
|
||||
<!--end-->
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -19,6 +19,17 @@
|
|||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.czg</groupId>
|
||||
<artifactId>system-service</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.apache.tomcat.embed</groupId>
|
||||
<artifactId>tomcat-embed-core</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
package com.czg;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableDiscoveryClient
|
||||
@EnableFeignClients
|
||||
@MapperScan("com.czg.service.system.mapper")
|
||||
public class SystemApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
package com.czg.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author GYJoker
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/feign")
|
||||
public class FeignController {
|
||||
|
||||
@RequestMapping("/testCall/{name}")
|
||||
public String testCall(@PathVariable String name) {
|
||||
return "system-server:" + name;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,17 +1,13 @@
|
|||
|
||||
spring:
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://rm-bp1kn7h89nz62cno1ro.mysql.rds.aliyuncs.com:3306/czg_cashier?useUnicode=true&characterEncoding=utf-8
|
||||
username: cashier
|
||||
password: Cashier@1@
|
||||
|
||||
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
|
||||
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ public class SaTokenConfigure implements WebMvcConfigurer {
|
|||
|
||||
SaRouter.match("/admin/**")
|
||||
.notMatch("/admin/auth/**")
|
||||
.notMatch("/admin/feign/**")
|
||||
.check(r -> StpKit.ADMIN.checkLogin());
|
||||
SaRouter.match("/user/**").check(r -> StpKit.USER.checkLogin());
|
||||
})).addPathPatterns("/**");
|
||||
|
|
|
|||
|
|
@ -22,6 +22,13 @@
|
|||
<sa-token.version>1.40.0</sa-token.version>
|
||||
<commons-io.version>2.14.0</commons-io.version>
|
||||
<tomcat-embed-core.version>11.0.2</tomcat-embed-core.version>
|
||||
<nacos-discovery.version>2023.0.3.2</nacos-discovery.version>
|
||||
<nacos-config.version>2023.0.3.2</nacos-config.version>
|
||||
<cloud-starter-bootstrap.version>4.1.4</cloud-starter-bootstrap.version>
|
||||
<cloud-starter-openfeign.version>4.2.0</cloud-starter-openfeign.version>
|
||||
<mysql-connector-j.version>8.2.0</mysql-connector-j.version>
|
||||
<mybatis-spring-boot.version>3.0.4</mybatis-spring-boot.version>
|
||||
<cloud-starter-loadbalancer.version>4.2.0</cloud-starter-loadbalancer.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
|
|
@ -100,6 +107,65 @@
|
|||
<version>${fastjson2.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Boot与nacos整合的核心依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
<version>${nacos-discovery.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 配置管理依赖,如果你需要配置管理功能 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
<version>${nacos-config.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||
<version>${cloud-starter-bootstrap.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--openfeign依赖-->
|
||||
<!--start-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
<version>${cloud-starter-openfeign.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>commons-io</groupId>-->
|
||||
<!-- <artifactId>commons-io</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!--end-->
|
||||
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
<version>${mysql-connector-j.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>${mybatis-spring-boot.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-loadbalancer -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
|
||||
<version>${cloud-starter-loadbalancer.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
package com.czg.feign;
|
||||
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
/**
|
||||
* @author GYJoker
|
||||
*/
|
||||
@FeignClient("system-server")
|
||||
public interface FeignSystemService {
|
||||
@GetMapping("/feign/testCall/{name}") // 使用 get 方式,调用服务提供者的 /call/{name} 接口
|
||||
String testCall(@PathVariable(value = "name") String name);
|
||||
}
|
||||
|
|
@ -28,11 +28,5 @@
|
|||
<artifactId>HikariCP</artifactId>
|
||||
<version>4.0.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
<version>8.2.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -56,5 +56,55 @@
|
|||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Boot与nacos整合的核心依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 配置管理依赖,如果你需要配置管理功能 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--openfeign依赖-->
|
||||
<!--start-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
</dependency>
|
||||
<!--end-->
|
||||
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.czg.service.system.service.impl;
|
||||
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.service.system.dto.SysParamsDTO;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.service.system.entity.SysParams;
|
||||
import com.czg.service.system.mapper.SysParamsMapper;
|
||||
|
|
@ -15,4 +17,13 @@ import org.springframework.stereotype.Service;
|
|||
@Service
|
||||
public class SysParamsServiceImpl extends ServiceImpl<SysParamsMapper, SysParams> implements SysParamsService{
|
||||
|
||||
@Override
|
||||
public CzgResult<Long> insertParams(SysParamsDTO paramsDTO) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CzgResult<SysParamsDTO> updateParams(SysParamsDTO paramsDTO) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue