提交 c54aa873 authored 作者: 陈世营's avatar 陈世营

spring-gateway init

上级 d7673dfb
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**
!**/src/test/**
logs/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
.idea/*
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
### VS Code ###
.vscode/
<?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>
<artifactId>demo</artifactId>
<groupId>com.loit</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>loit-gateway</artifactId>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<springfox-swagger-ui.version>2.9.2</springfox-swagger-ui.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<!-- nacos 配置中心 -->
<dependency>
<groupId>com.timeloit.cloud</groupId>
<artifactId>spring-cloud-starter-timeloit-nacos-config</artifactId>
</dependency>
<!-- nacos 注册中心 -->
<dependency>
<groupId>com.timeloit.cloud</groupId>
<artifactId>spring-cloud-starter-timeloit-nacos-discovery</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!-- sentinel gateway流控 -->
<dependency>
<groupId>com.timeloit.cloud</groupId>
<artifactId>spring-cloud-starter-timeloit-sentinel</artifactId>
</dependency>
<dependency>
<groupId>com.timeloit.cloud</groupId>
<artifactId>spring-cloud-timeloit-sentinel-gateway</artifactId>
</dependency>
<!-- sentinel nacos 整合 -->
<dependency>
<groupId>com.timeloit.cloud</groupId>
<artifactId>spring-cloud-timeloit-sentinel-datasource</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-datasource-nacos</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!--网关集成swagger SpringBoot swagger2 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${springfox-swagger-ui.version}</version>
</dependency>
<!-- 网关集成swagger SpringBoot swagger2 -UI -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${springfox-swagger-ui.version}</version>
</dependency>
<dependency>
<groupId>com.loit</groupId>
<artifactId>loit-portal-api</artifactId>
<version>1.0.3</version>
</dependency>
<!-- 微服务:Feign -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
</dependencies>
<build>
<finalName>loit-getway</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<!-- 配置java版本 不配置的话默认父类配置的是1.6-->
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.loit.getway.GateWayApplication</mainClass>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
\ No newline at end of file
package com.loit.getway;
import org.springframework.boot.SpringApplication;
import org.springframework.cloud.client.SpringCloudApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.scheduling.annotation.EnableScheduling;
/**
* 项目启动
*
* @author wbh
*/
@EnableHystrix
@EnableScheduling
@SpringCloudApplication
@EnableDiscoveryClient
@EnableFeignClients
public class GateWayApplication {
public static void main(String[] args) {
long startTime=System.currentTimeMillis();
SpringApplication.run(GateWayApplication.class, args);
long endTime=System.currentTimeMillis();
float excTime=(float)(endTime-startTime)/1000;
System.out.println("############--- loit-getway项目启动成功,执行用时:"+excTime+"秒 ---############");
}
}
\ No newline at end of file
server:
port: 7001
#权限配置
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: ALWAYS
info:
name: '@project.name@'
description: '@project.description@'
spring:
application:
name: loit-getway
cloud:
nacos:
discovery:
# Nacos 注册中心地址
server-addr: 47.114.50.99:8010
namespace: 46c2400a-5773-4c26-be68-2e90a673259b
metadata:
management:
context-path: /actuator
gateway:
discovery: #是否与服务发现组件进行结合,通过 serviceId(必须设置成大写) 转发到具体的服务实例。默认为false,设为true便开启通过服务中心的自动根据 serviceId 创建路由的功能。
locator: #路由访问方式:http://Gateway_HOST:Gateway_PORT/大写的serviceId/**,其中微服务应用名默认大写访问,配置lowerCaseServiceId可用小写。
enabled: true
lowerCaseServiceId: true
routes:
- id: loit-portal
uri: lb://loit-portal
predicates:
- Path=/api-portal/**
filters:
- StripPrefix=1
logoutSign: true
- id: loit-file
uri: lb://loit-file
predicates:
- Path=/api-file/**
filters:
- StripPrefix=1
- id: loit-law
uri: lb://loit-law
predicates:
- Path=/api-law/**
filters:
- StripPrefix=1
- id: loit-form
uri: lb://loit-form
predicates:
- Path=/api-form/**
filters:
- StripPrefix=1
- id: loit-admin-server
uri: lb://loit-admin-server
predicates:
- Path=/api-admin/**
filters:
- StripPrefix=1
- id: loit-cas-server
uri: lb://loit-cas-server
predicates:
- Path=/loit-cas/**
filters:
- StripPrefix=1
casServerSign: true
- id: loit-notice
uri: lb://loit-notice
predicates:
- Path=/api-notice/**
filters:
- StripPrefix=1
sentinel:
# Sentinel 网关限流规则配置文件
datasource.ds1.nacos:
server-addr: 47.114.50.99:8010
namespace: 46c2400a-5773-4c26-be68-2e90a673259b
data-id: ${spring.application.name}-sentinel-gateway
data-type: json
group-id: DEFAULT_GROUP
# 规则类型 限流配置
ruleType: gw-flow
# Sentinel 网关限流API分组定义配置文件
datasource.ds2.nacos:
server-addr: 47.114.50.99:8010
namespace: 46c2400a-5773-4c26-be68-2e90a673259b
data-id: ${spring.application.name}-sentinel-api
data-type: json
group-id: DEFAULT_GROUP
# 规则类型 API分组
ruleType: gw-api-group
# Sentinel 网关降级规则配置
datasource.ds3.nacos:
server-addr: 47.114.50.99:8010
namespace: 46c2400a-5773-4c26-be68-2e90a673259b
data-id: ${spring.application.name}-degrade-rules
data-type: json
group-id: DEFAULT_GROUP
# 规则类型 降级
ruleType: degrade
## 应用与Sentinel控制台交互的端口,应用本地会起一个该端口占用的HttpServer
#transport:
## Sentinel 控制台地址
#dashboard: localhost:8090
## 应用与Sentinel控制台的心跳间隔时间
#heartbeat-interval-ms: 60000
#port: 8719
filter:
enabled: true
scg.fallback:
## Spring Cloud Gateway 熔断后的响应模式(选择 redirect or response)
mode: response
## Spring Cloud Gateway 响应模式为 'response' 模式对应的响应码
response-status: 200
content-type: application/json
## Spring Cloud Gateway 响应模式为 'response' 模式对应的响应内容
response-body: '{"success":false,"code":"444","msg":"系统繁忙请稍后再试"}'
scg:
order: -100
redis:
database: 2
host: 127.0.0.1
port: 6379
jedis:
pool:
max-idle: 20
min-idle: 0
max-active: 8
max-wait: -1
timeout: 10000
#password: portal2019
# 单点登录配置
loit:
cas:
gateway:
resource_auth: false
login_auth: false
kill_seconds: 1800
gateway_debug_out: true
#放行路径
auth-skip:
dataworks-servers:
- api-portal
no-user-servers:
- /loit-cas/**
no-user-uri:
- /image/**
- /static/**
api-urls:
#portal模块测试与生产环境放行接口
- /api-portal/api/v1/feign/dict/**
- /api-portal/cas/**
- /api-portal/api/v1/cas/**
- /api-portal/image/**
- /api-portal/api/v1/dictData/**
- /api-portal/actuator/**
- /api-portal/actuator/health
#portal模块开发放行接口
- /api-portal/api/v1/person/setCookie/**
- /api-portal/api/v1/feign/org/treeList
- /api-portal/api/v1/open/person/orgPersonList/**
- /api-portal/login.html
- /api-portal/static/**
- /api-portal/api/v1/app/login
- /api-portal/websocket
#Case单点登录放行接口
- /loit-cas/cas/**
#swagger开发测试放行接口
- /*/swagger-ui.html
- /*/swagger-resources/**
- /*/v2/api-docs
- /*/webjars/springfox-swagger-ui/**
#file模块
#- /v1/datasetshare
#- /health
spring.profiles.active=dev
spring.application.name=loit-getway
# Nacos \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u0135\ufffd\u05b7
spring.cloud.nacos.config.server-addr=47.114.50.99:8010
spring.cloud.nacos.config.namespace=46c2400a-5773-4c26-be68-2e90a673259b
spring.cloud.nacos.config.file-extension=yaml
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<modules>
<module>loit-gateway</module>
</modules>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.loit</groupId>
<artifactId>demo</artifactId>
<packaging>pom</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<spring-boot-admin.version>2.3.0</spring-boot-admin.version>
<spring-cloud.version>Hoxton.SR8</spring-cloud.version>
<spring-cloud-timeloit.version>2.3.3-SNAPSHOT</spring-cloud-timeloit.version>
</properties>
<!--<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</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-zookeeper</artifactId>
&lt;!&ndash; <version>2.2.1.RELEASE</version>&ndash;&gt;
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
&lt;!&ndash; <version>2.2.2.RELEASE</version>&ndash;&gt;
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>-->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-dependencies</artifactId>
<version>${spring-boot-admin.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- 时代凌宇 基础组件 -->
<dependency>
<groupId>com.timeloit.cloud</groupId>
<artifactId>spring-cloud-timeloit</artifactId>
<version>${spring-cloud-timeloit.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<distributionManagement>
<repository>
<id>nexus-releases</id>
<name>Nexus Release Repository</name>
<url>http://39.100.254.140:12010/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>nexus-snapshots</id>
<name>Nexus Snapshot Repository</name>
<url>http://39.100.254.140:12010/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
<repositories>
<repository>
<id>nexus-loit-dev</id>
<name>Nexus Repository</name>
<url>http://39.100.254.140:12010/repository/maven-public/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus-loit-dev</id>
<name>Nexus Plugin Repository</name>
<url>http://39.100.254.140:12010/repository/maven-public/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
</project>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论