This commit is contained in:
cuijiawang 2025-08-05 10:47:14 +08:00
commit 861fbeff57
8 changed files with 222 additions and 0 deletions

33
.gitignore vendored Normal file
View File

@ -0,0 +1,33 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/

10
Dockerfile Normal file
View File

@ -0,0 +1,10 @@
#FROM openjdk:8
FROM amazoncorretto:17
MAINTAINER yunchengxinchuang@163.com
ADD target/gateway-0.0.1.jar /gateway.jar
#ADD target/saas-jjt-h5-api.jar /dnxb-app.jar
EXPOSE 8080
ENV SERVER_PORT 8080
ENV CONTEXT_PATH /
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
ENTRYPOINT ["java", "-jar", "/gateway.jar"]

61
pom.xml Normal file
View File

@ -0,0 +1,61 @@
<?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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.10</version>
</parent>
<groupId>com.example</groupId>
<artifactId>gateway</artifactId>
<version>0.0.1</version>
<name>demo</name>
<properties>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.jujia</groupId>
<artifactId>jujia-common-config</artifactId>
<version>1.2.7-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
<version>3.1.7</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
<version>3.1.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>public</id>
<name>public</name>
<url>http://8.148.4.157:8081/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
</repository>
</repositories>
</project>

View File

@ -0,0 +1,17 @@
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;
@SpringBootApplication
@EnableDiscoveryClient
@RefreshScope
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}

View File

@ -0,0 +1,17 @@
package com.example.demo;
import org.springframework.cloud.context.scope.refresh.RefreshScopeRefreshedEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
/**
* @Author cuiJiaWang
* @Create 2025-03-29 15:47
*/
@Component
public class Listener {
@EventListener
public void onRefresh(RefreshScopeRefreshedEvent event) {
System.out.println("配置已刷新,重新加载路由规则!");
}
}

View File

@ -0,0 +1,57 @@
server:
port: 8888
spring:
cloud:
gateway:
discovery:
locator:
enabled: true
routes:
- id: yuncheng-bpm
uri: lb://yuncheng-bpm
predicates:
- Path=/api/bpm/**
- id: yuncheng-eform
uri: lb://yuncheng-jjt-eform
predicates:
- Path=/api/eform/**
- id: yuncheng-ureport
uri: lb://yuncheng-ureport
predicates:
- Path=/ureport/**
- id: yuncheng-magic
uri: lb://yuncheng-magic
predicates:
- Path=/magic/**
- id: yuncheng-jjt
uri: lb://yuncheng-jjt
predicates:
- Path=/jjsaas/**
- id: yuncheng-enc
uri: lb://jujia-enc
predicates:
- Path=/enc/**
- id: yuncheng-market
uri: lb://jjt-market
predicates:
- Path=/api/jjtmarket/**
- id: jjt-health
uri: lb://jjt-health
predicates:
- Path=/api/jjthealth/**
- id: jjt-health
uri: lb://jjt-travel
predicates:
- Path=/api/travel/**
- id: jjt-payment
uri: lb://jjt-payment
predicates:
- Path=/api/jjtpay/**
- id: jjt-order
uri: lb://jjt-order
predicates:
- Path=/api/jjtOrder/**
- id: yuncheng-system
uri: lb://yuncheng-jjt-system
predicates:
- Path=/**

View File

@ -0,0 +1,3 @@
spring:
profiles:
active: dev

View File

@ -0,0 +1,24 @@
spring:
application:
name: jjt-gateway
cloud:
nacos:
config:
#nacos配置中心地址
server-addr: ${NACOS_SERVER:192.168.110.27:8848}
file-extension: yaml
namespace: ${NACOS_CONFIG_NAMESPACE:public}
username: ${NACOS_USERNAME:}
password: ${NACOS_PASSWORD:}
refresh-enabled: true
enabled: ${NACOS_ENABLED:true}
discovery:
#nacos注册中心地址
server-addr: ${NACOS_SERVER:192.168.110.27:8848}
ip: ${NACOS_IP:192.168.110.27}
service: ${NACOS_SERVICE:jjt-gateway}
namespace: ${NACOS_DISCOVERY_NAMESPACE:public}
username: ${NACOS_USERNAME:}
password: ${NACOS_PASSWORD:}
enabled: ${NACOS_ENABLED:true}