添加网关服务,更新包名

This commit is contained in:
2026-02-02 17:00:42 +08:00
parent b271f0aa87
commit 5d8816fb2f
54 changed files with 238 additions and 110 deletions
+49
View File
@@ -0,0 +1,49 @@
<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>
<parent>
<groupId>top.crushtj</groupId>
<artifactId>xiaoyishu</artifactId>
<version>${revision}</version>
</parent>
<artifactId>xiaoyi-gateway</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<description>网关服务</description>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
<!-- 服务发现 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</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-loadbalancer</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,20 @@
package top.crushtj.xiaoyi.gateway;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @author ayi
* @version V1.0
* @title XiaoyiGatewayApplication
* @date 2026/2/2 16:46
* @description 网关启动类
*/
@SpringBootApplication
public class XiaoyiGatewayApplication {
public static void main(String[] args) {
SpringApplication.run(XiaoyiGatewayApplication.class, args);
}
}
@@ -0,0 +1,12 @@
server:
port: 8000 # 指定启动端口
spring:
cloud:
gateway:
routes:
- id: auth
uri: lb://xiaoyishu-auth
predicates:
- Path=/auth/**
filters:
- StripPrefix=1
@@ -0,0 +1,12 @@
spring:
application:
name: xiaoyi-gateway # 应用名称
profiles:
active: dev
cloud:
nacos:
discovery:
enabled: true # 启用服务发现
group: DEFAULT_GROUP # 所属组
namespace: xiaoyishu # 命名空间
server-addr: 127.0.0.1:8848 # Nacos 服务器地址
@@ -0,0 +1,38 @@
package top.crushtj.xiaoyi.gateway;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}