mirror of
https://gitee.com/dromara/MaxKey.git
synced 2025-12-08 01:48:33 +08:00
maxkey-gataway init
This commit is contained in:
parent
77d00809dd
commit
81b343527a
52
maxkey-gataway/build.gradle
Normal file
52
maxkey-gataway/build.gradle
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
description = "maxkey-gateway"
|
||||||
|
|
||||||
|
//add support for Java
|
||||||
|
apply plugin: 'java'
|
||||||
|
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation project(":maxkey-common")
|
||||||
|
|
||||||
|
//spring-cloud gateway server
|
||||||
|
implementation group: 'org.springframework.cloud', name: 'spring-cloud-gateway-server', version: "${springcloudVersion}"
|
||||||
|
implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-gateway', version: "${springcloudVersion}"
|
||||||
|
//spring-cloud loadbalancer
|
||||||
|
implementation group: 'org.springframework.cloud', name: 'spring-cloud-loadbalancer', version: "${springcloudVersion}"
|
||||||
|
implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-loadbalancer', version: "${springcloudVersion}"
|
||||||
|
//spring-cloud netflix-hystrix
|
||||||
|
implementation group: 'org.springframework.cloud', name: 'spring-cloud-netflix-hystrix', version: '2.2.9.RELEASE'
|
||||||
|
implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-netflix-hystrix', version: '2.2.9.RELEASE'
|
||||||
|
|
||||||
|
//spring-cloud-alibaba
|
||||||
|
implementation group: 'com.alibaba.cloud', name: 'spring-cloud-circuitbreaker-sentinel', version: "${springcloudalibabaVersion}"
|
||||||
|
implementation group: 'com.alibaba.cloud', name: 'spring-cloud-alibaba-sentinel-datasource', version: "${springcloudalibabaVersion}"
|
||||||
|
implementation group: 'com.alibaba.cloud', name: 'spring-cloud-alibaba-sentinel-gateway', version: "${springcloudalibabaVersion}"
|
||||||
|
implementation group: 'com.alibaba.cloud', name: 'spring-cloud-starter-alibaba-sentinel', version: "${springcloudalibabaVersion}"
|
||||||
|
|
||||||
|
//spring-cloud-alibaba sentinel
|
||||||
|
implementation group: 'com.alibaba.csp', name: 'sentinel-annotation-aspectj', version: "${springcloudalibabacsplVersion}"
|
||||||
|
implementation group: 'com.alibaba.csp', name: 'sentinel-api-gateway-adapter-common', version: "${springcloudalibabacsplVersion}"
|
||||||
|
implementation group: 'com.alibaba.csp', name: 'sentinel-core', version: "${springcloudalibabacsplVersion}"
|
||||||
|
implementation group: 'com.alibaba.csp', name: 'sentinel-cluster-common-default', version: "${springcloudalibabacsplVersion}"
|
||||||
|
implementation group: 'com.alibaba.csp', name: 'sentinel-cluster-client-default', version: "${springcloudalibabacsplVersion}"
|
||||||
|
implementation group: 'com.alibaba.csp', name: 'sentinel-cluster-server-default', version: "${springcloudalibabacsplVersion}"
|
||||||
|
implementation group: 'com.alibaba.csp', name: 'sentinel-datasource-extension', version: "${springcloudalibabacsplVersion}"
|
||||||
|
implementation group: 'com.alibaba.csp', name: 'sentinel-parameter-flow-control', version: "${springcloudalibabacsplVersion}"
|
||||||
|
implementation group: 'com.alibaba.csp', name: 'sentinel-reactor-adapter', version: "${springcloudalibabacsplVersion}"
|
||||||
|
implementation group: 'com.alibaba.csp', name: 'sentinel-transport-common', version: "${springcloudalibabacsplVersion}"
|
||||||
|
implementation group: 'com.alibaba.csp', name: 'sentinel-transport-simple-http', version: "${springcloudalibabacsplVersion}"
|
||||||
|
implementation group: 'com.alibaba.csp', name: 'sentinel-spring-cloud-gateway-adapter', version: "${springcloudalibabacsplVersion}"
|
||||||
|
implementation group: 'com.alibaba.csp', name: 'sentinel-spring-webflux-adapter', version: "${springcloudalibabacsplVersion}"
|
||||||
|
implementation group: 'com.alibaba.csp', name: 'sentinel-spring-webmvc-adapter', version: "${springcloudalibabacsplVersion}"
|
||||||
|
//netty
|
||||||
|
implementation group: 'io.projectreactor.netty', name: 'reactor-netty', version: "${reactornettyVersion}"
|
||||||
|
implementation group: 'io.projectreactor.netty', name: 'reactor-netty-http', version: "${reactornettyVersion}"
|
||||||
|
implementation group: 'io.projectreactor.netty', name: 'reactor-netty-core', version: "${reactornettyVersion}"
|
||||||
|
implementation group: 'io.projectreactor.addons', name: 'reactor-extra', version: "${reactorextraVersion}"
|
||||||
|
|
||||||
|
implementation group: 'com.googlecode.concurrentlinkedhashmap', name: 'concurrentlinkedhashmap-lru', version: "${concurrentlinkedhashmaplruVersion}"
|
||||||
|
implementation group: 'com.stoyanr', name: 'evictor', version: "${evictorVersion}"
|
||||||
|
implementation group: 'jakarta.annotation', name: 'jakarta.annotation-api', version: "${jakartaannotationVersion}"
|
||||||
|
implementation group: 'io.lettuce', name: 'lettuce-core', version: "${lettuceVersion}"
|
||||||
|
implementation group: 'io.netty', name: 'netty-all', version: "${nettyVersion}"
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
package org.gateway;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
|
||||||
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||||
|
|
||||||
|
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
|
||||||
|
|
||||||
|
|
||||||
|
@SpringBootApplication(
|
||||||
|
exclude={
|
||||||
|
RedisAutoConfiguration.class,
|
||||||
|
DruidDataSourceAutoConfigure.class,
|
||||||
|
DataSourceAutoConfiguration.class
|
||||||
|
})
|
||||||
|
@EnableDiscoveryClient
|
||||||
|
public class GatewayApplication {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(GatewayApplication.class, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
54
maxkey-gataway/src/main/resources/application.yml
Normal file
54
maxkey-gataway/src/main/resources/application.yml
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
#端口号
|
||||||
|
application:
|
||||||
|
name: maxkey-gateway-server
|
||||||
|
formatted-version: v2.9.0 GA
|
||||||
|
server:
|
||||||
|
port: 9000
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
name: maxkey-gateway-server
|
||||||
|
cloud:
|
||||||
|
gateway:
|
||||||
|
routes:
|
||||||
|
#nacos健康检查端口8080
|
||||||
|
- id: maxkeys_route
|
||||||
|
uri: lb://maxkey
|
||||||
|
filters:
|
||||||
|
- PrefixPath=/
|
||||||
|
predicates:
|
||||||
|
- Path=/maxkey/**
|
||||||
|
- id: maxkey_mgts_route
|
||||||
|
uri: lb://maxkey-mgt
|
||||||
|
filters:
|
||||||
|
- PrefixPath=/
|
||||||
|
predicates:
|
||||||
|
- Path=/maxkey-mgt/**
|
||||||
|
# default-filters:
|
||||||
|
# - name: Hystrix
|
||||||
|
# args:
|
||||||
|
# name: default
|
||||||
|
# fallbackUri: 'forward:/defaultFallback'
|
||||||
|
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
server-addr: ${NACOS_DISCOVERY_SERVER_ADDR:127.0.0.1:8848}
|
||||||
|
enabled: ${NACOS_DISCOVERY_ENABLED:true}
|
||||||
|
config:
|
||||||
|
# file-extension: yaml
|
||||||
|
# server-addr: 127.0.0.1:8848
|
||||||
|
username: ${NACOS_CONFIG_USERNAME:nacos}
|
||||||
|
password: ${NACOS_CONFIG_PASSWORD:nacos}
|
||||||
|
|
||||||
|
main:
|
||||||
|
web-application-type: reactive
|
||||||
|
#spring.main.web-application-type=reactive
|
||||||
|
hystrix:
|
||||||
|
command:
|
||||||
|
default:
|
||||||
|
execution:
|
||||||
|
isolation:
|
||||||
|
strategy: SEMAPHORE
|
||||||
|
thread:
|
||||||
|
#1分钟服务无响应则直接熔断
|
||||||
|
timeoutInMilliseconds: 60000
|
||||||
|
|
||||||
12
maxkey-gataway/src/main/resources/bootstrap.properties
Normal file
12
maxkey-gataway/src/main/resources/bootstrap.properties
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
spring.cloud.nacos.config.server-addr =${NACOS_CONFIG_SERVER_ADDR:127.0.0.1:8848}
|
||||||
|
|
||||||
|
# Nacos \u63A7\u5236\u53F0\u6DFB\u52A0\u914D\u7F6E\uFF1A
|
||||||
|
# Data ID\uFF1Amaxkey-gateway.properties
|
||||||
|
# Group\uFF1ADEFAULT_GROUP
|
||||||
|
# \u914D\u7F6E\u5185\u5BB9\uFF1AuseLocalCache=true
|
||||||
|
spring.application.name =maxkey-gateway
|
||||||
|
# \u6307\u5B9A\u914D\u7F6E\u7684\u540E\u7F00\uFF0C\u652F\u6301 properties\u3001yaml\u3001yml\uFF0C\u9ED8\u8BA4\u4E3A properties
|
||||||
|
spring.cloud.nacos.config.file-extension =properties
|
||||||
|
#spring.cloud.nacos.config.file-extension=yaml
|
||||||
|
#\u662F\u5426\u542F\u7528nacos\u914D\u7F6E
|
||||||
|
spring.cloud.nacos.config.enabled =${NACOS_CONFIG_ENABLED:false}
|
||||||
33
maxkey-gataway/src/main/resources/log4j2.xml
Normal file
33
maxkey-gataway/src/main/resources/log4j2.xml
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Configuration status="INFO" monitorInterval="300">
|
||||||
|
<Appenders>
|
||||||
|
<Console name="consolePrint" target="SYSTEM_OUT">
|
||||||
|
<PatternLayout pattern="%d{YYYY-MM-dd HH:mm:ss,SSS} %-5level [%t] %logger{36}:%L - %msg%n" />
|
||||||
|
</Console>
|
||||||
|
|
||||||
|
<!-- 输出到文件,按天或者超过128MB分割 每天进行归档yyyy-MM-dd -->
|
||||||
|
<RollingFile name="RollingFile" fileName="logs/maxkey-gateway.log" filePattern="logs/$${date:yyyyMMdd}/maxkey-gateway-%d{yyyy-MM-dd}-%i.log.gz">
|
||||||
|
<!-- 需要记录的级别 -->
|
||||||
|
<!-- <ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY" /> -->
|
||||||
|
<PatternLayout pattern="%d{YYYY-MM-dd HH:mm:ss,SSS} %-5level [%t] %logger{36}:%L - %msg%n" />
|
||||||
|
<Policies>
|
||||||
|
<OnStartupTriggeringPolicy />
|
||||||
|
<TimeBasedTriggeringPolicy />
|
||||||
|
<SizeBasedTriggeringPolicy size="128 MB" />
|
||||||
|
</Policies>
|
||||||
|
<DefaultRolloverStrategy max="100"/>
|
||||||
|
</RollingFile>
|
||||||
|
</Appenders>
|
||||||
|
|
||||||
|
<Loggers>
|
||||||
|
<Logger level="INFO" name="org.springframework" ></Logger>
|
||||||
|
<Logger level="INFO" name="org.apache.logging" ></Logger>
|
||||||
|
<Logger level="DEBUG" name="org.maxkey" ></Logger>
|
||||||
|
<Logger level="ERROR" name="org.reflections.Reflections" ></Logger>
|
||||||
|
|
||||||
|
<Root level="INFO">
|
||||||
|
<AppenderRef ref="consolePrint" />
|
||||||
|
<AppenderRef ref="RollingFile" />
|
||||||
|
</Root >
|
||||||
|
</Loggers>
|
||||||
|
</Configuration>
|
||||||
Loading…
x
Reference in New Issue
Block a user