集成eureka注册中心、feign调用。

This commit is contained in:
wangzhijiang
2022-02-15 18:08:39 +08:00
parent ff9c1d7d1e
commit fd1125a1c2
11 changed files with 187 additions and 0 deletions
+59
View File
@@ -0,0 +1,59 @@
<?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">
<parent>
<groupId>com.jero.boot</groupId>
<artifactId>jero-boot</artifactId>
<version>2.4.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jero-boot-center</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>jero-boot-center</name>
<description>蔚来项目-注册发现中心</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<skipTests>true</skipTests>
</properties>
<repositories>
<repository>
<id>maven-central</id>
<name>maven-central</name>
<url>http://121.36.69.172:4000/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>competing-center</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,17 @@
package com.adc.da;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
/**
* eureka注册发现中心
*/
@EnableEurekaServer
@SpringBootApplication
public class CenterApplication {
public static void main(String[] args) {
SpringApplication.run(CenterApplication.class, args);
}
}
@@ -0,0 +1,20 @@
server:
port: 8123
eurekt:
server:
responseCacheUpdateInvervalMs: 3000
eureka:
server:
enable-self-preservation: false
responseCacheAutoExpirationInSeconds: 180
eviction-interval-timer-in-ms: 4000
client:
register-with-eureka: false
fetch-registry: false
service-url:
defaultZone: http://localhost:8123/eureka/
ribbon:
ConnectTimeout: 360000
MaxAutoRetries: 2
MaxAutoRetriesNextServer: 1
ReadTimeout: 360000
@@ -0,0 +1,20 @@
server:
port: 8888
eurekt:
server:
responseCacheUpdateInvervalMs: 3000
eureka:
server:
enable-self-preservation: false
responseCacheAutoExpirationInSeconds: 180
eviction-interval-timer-in-ms: 4000
client:
register-with-eureka: false
fetch-registry: false
service-url:
defaultZone: http://localhost:8888/eureka/
ribbon:
ConnectTimeout: 360000
MaxAutoRetries: 2
MaxAutoRetriesNextServer: 1
ReadTimeout: 360000
@@ -0,0 +1,20 @@
server:
port: 8888
eurekt:
server:
responseCacheUpdateInvervalMs: 3000
eureka:
server:
enable-self-preservation: false
responseCacheAutoExpirationInSeconds: 180
eviction-interval-timer-in-ms: 4000
client:
register-with-eureka: false
fetch-registry: false
service-url:
defaultZone: http://localhost:8888/eureka/
ribbon:
ConnectTimeout: 60000
MaxAutoRetries: 2
MaxAutoRetriesNextServer: 1
ReadTimeout: 60000
@@ -0,0 +1,3 @@
spring:
profiles:
active: dev
@@ -0,0 +1,9 @@
${AnsiColor.RED} _ _
__ _ __| | ___ __| | __ _
/ _` |/ _` |/ __|____ / _` |/ _` |
| (_| | (_| | (_|_____| (_| | (_| |
\__,_|\__,_|\___| \__,_|\__,_|
${AnsiColor.YELLOW}------------------------------------------------
${AnsiColor.YELLOW} :: ${AnsiColor.YELLOW}@数据资源中心
${AnsiColor.YELLOW}------------------------------------------------${AnsiColor.WHITE}
@@ -0,0 +1,16 @@
package com.adc.da;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class ApplicationTests {
@Test
public void contextLoads() {
}
}
@@ -32,6 +32,16 @@
<artifactId>jero-boot-modules</artifactId>
<version>${jero.version}</version>
</dependency>
<!--eureka注册中心-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<!-- feign调用 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
</dependencies>
<build>
@@ -6,6 +6,8 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
@@ -19,6 +21,8 @@ import java.net.UnknownHostException;
**/
@Slf4j
@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients
public class LawNioApplication extends SpringBootServletInitializer {
@Override
@@ -292,3 +292,12 @@ justauth:
type: default
prefix: 'demo::'
timeout: 1h
## eureka注册中心
eureka:
client:
#是否将自己注册到Eureka Server上,默认为true
register-with-eureka: true
##是否从Eureka Server上获取注册信息,默认为true
fetch-registry: true
service-url:
defaultZone: http://127.0.0.1:8123/eureka/