feign client
This commit is contained in:
commit
1b47f5a122
|
@ -0,0 +1 @@
|
|||
* text=auto eol=lf
|
|
@ -0,0 +1,28 @@
|
|||
# Build and Release Folders
|
||||
target/
|
||||
|
||||
# Eclipse
|
||||
.settings/
|
||||
*.classpath
|
||||
*.project
|
||||
*.factorypath
|
||||
|
||||
# IntelliJ IDEA
|
||||
.idea
|
||||
*.iml
|
||||
|
||||
# vscode
|
||||
.vscode
|
||||
|
||||
# JRebel
|
||||
rebel.xml
|
||||
|
||||
# macOS
|
||||
.DS_Store
|
||||
|
||||
# svn
|
||||
.svn/
|
||||
|
||||
# vue
|
||||
kernel-standard/
|
||||
node_modules/
|
|
@ -0,0 +1,112 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>net.risesoft</groupId>
|
||||
<artifactId>demo01-client</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>1.0</version>
|
||||
<name>demo01-client</name>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.2.2</version>
|
||||
<relativePath /> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<java.version>21</java.version>
|
||||
</properties>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>gitea</id>
|
||||
<url>https://svn.youshengyun.com:3000/api/packages/risesoft/maven</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>gitea</id>
|
||||
<url>https://svn.youshengyun.com:3000/api/packages/risesoft/maven</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>2023.0.0</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>jakarta.servlet</groupId>
|
||||
<artifactId>jakarta.servlet-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</exclude>
|
||||
</excludes>
|
||||
<mainClass>net.risesoft.demo.Demo01Application</mainClass>
|
||||
<image>
|
||||
<env>
|
||||
<BP_NATIVE_IMAGE>false</BP_NATIVE_IMAGE>
|
||||
<BP_JVM_VERSION>21</BP_JVM_VERSION>
|
||||
</env>
|
||||
<name>svn.youshengyun.com:9923/${project.artifactId}-jvm:${project.version}</name>
|
||||
<publish>true</publish>
|
||||
</image>
|
||||
<docker>
|
||||
<publishRegistry>
|
||||
<username>publisher</username>
|
||||
<password>83204585</password>
|
||||
</publishRegistry>
|
||||
</docker>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,17 @@
|
|||
package net.risesoft.demo;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableDiscoveryClient
|
||||
@EnableFeignClients
|
||||
public class FeignClientApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(FeignClientApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package net.risesoft.demo;
|
||||
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
import org.springframework.web.WebApplicationInitializer;
|
||||
|
||||
public class ServletInitializer extends SpringBootServletInitializer implements WebApplicationInitializer {
|
||||
|
||||
@Override
|
||||
protected SpringApplicationBuilder configure(final SpringApplicationBuilder builder) {
|
||||
setRegisterErrorPageFilter(false);
|
||||
builder.sources(FeignClientApplication.class);
|
||||
return builder;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package net.risesoft.demo.client;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
@FeignClient(name = "demo01", contextId = "ClientA", path="/demo01")
|
||||
public interface ClientA {
|
||||
|
||||
@GetMapping("/")
|
||||
List<String> hosts();
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package net.risesoft.demo.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import net.risesoft.demo.client.ClientA;
|
||||
|
||||
@RestController
|
||||
@RequestMapping
|
||||
public class mainController {
|
||||
|
||||
@Autowired
|
||||
ClientA client;
|
||||
|
||||
@RequestMapping("/")
|
||||
public List<String> hosts() {
|
||||
return client.hosts();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
management:
|
||||
endpoint:
|
||||
health:
|
||||
show-details: always
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: '*'
|
||||
server:
|
||||
port: 8081
|
||||
servlet:
|
||||
context-path: /demo01-client
|
||||
encoding:
|
||||
charset: UTF-8
|
||||
enabled: true
|
||||
force: true
|
||||
force-request: true
|
||||
force-response: true
|
||||
session:
|
||||
cookie:
|
||||
http-only: true
|
||||
secure: false
|
||||
timeout: 300
|
||||
tracking-modes: COOKIE
|
||||
shutdown: graceful
|
||||
ssl:
|
||||
enabled: false
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: demo01-client
|
||||
cloud:
|
||||
compatibility-verifier:
|
||||
enabled: false
|
||||
consul:
|
||||
host: ${CONSUL_HOST:localhost}
|
||||
port: ${CONSUL_PORT:8500}
|
||||
discovery:
|
||||
register-health-check: true
|
||||
healthCheckPath: ${server.servlet.context-path}/actuator/health
|
||||
healthCheckInterval: 15s
|
||||
metadata:
|
||||
metrics: ${server.servlet.context-path}/actuator/prometheus
|
||||
springboot: true
|
||||
isv: risesoft
|
||||
tags:
|
||||
- traefik.enable=true
|
||||
- traefik.http.routers.demo01.rule=PathPrefix(`/users`,`/actuator`)
|
||||
prefer-ip-address: true
|
||||
instance-id: ${spring.application.name}:${spring.application.instance-id:${random.value}}
|
||||
service-name: ${spring.application.name}
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
allow-circular-references: false
|
||||
lazy-initialization: false
|
||||
keep-alive: true
|
||||
threads:
|
||||
virtual:
|
||||
enabled: false
|
Loading…
Reference in New Issue