新增 gateway 模块
This commit is contained in:
parent
4eef6ba57f
commit
aa27bef61a
38
gateway/pom.xml
Normal file
38
gateway/pom.xml
Normal file
@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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>com.yovinchen</groupId>
|
||||
<artifactId>train</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>gateway</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-gateway</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<scope>runtime</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
</project>
|
@ -0,0 +1,30 @@
|
||||
package com.yovinchen.train.gateway;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
/**
|
||||
* ClassName: GatewayApplication
|
||||
* Package: com.yovinchen.train.gateway
|
||||
*
|
||||
* @author yovinchen
|
||||
* @Create 2024/1/19 14:32
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@ComponentScan("com.yovinchen")
|
||||
public class GatewayApplication {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(GatewayApplication.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication app = new SpringApplication(GatewayApplication.class);
|
||||
Environment env = app.run(args)
|
||||
.getEnvironment();
|
||||
LOG.info("启动成功!!");
|
||||
LOG.info("网关地址: \thttp://127.0.0.1:{}", env.getProperty("server.port"));
|
||||
}
|
||||
}
|
2
gateway/src/main/resources/application.yml
Normal file
2
gateway/src/main/resources/application.yml
Normal file
@ -0,0 +1,2 @@
|
||||
server:
|
||||
port: 8000
|
56
gateway/src/main/resources/logback-spring.xml
Normal file
56
gateway/src/main/resources/logback-spring.xml
Normal file
@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<!-- 修改一下路径-->
|
||||
<springProperty scope="context" name="APP_NAME" source="spring.application.name" defaultValue="springBoot"/>
|
||||
<property name="PATH" value="./log/${APP_NAME}"/>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %highlight(%-5level) %blue(%-50logger{50}:%-4line) %thread
|
||||
%green(%-18X{LOG_ID}) %msg%n
|
||||
</Pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="TRACE_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${PATH}/trace.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<FileNamePattern>${PATH}/trace.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
|
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||
<maxFileSize>10MB</maxFileSize>
|
||||
</timeBasedFileNamingAndTriggeringPolicy>
|
||||
</rollingPolicy>
|
||||
<layout>
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %-50logger{50}:%-4line %green(%-18X{LOG_ID}) %msg%n</pattern>
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${PATH}/error.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<FileNamePattern>${PATH}/error.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
|
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||
<maxFileSize>10MB</maxFileSize>
|
||||
</timeBasedFileNamingAndTriggeringPolicy>
|
||||
</rollingPolicy>
|
||||
<layout>
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %-50logger{50}:%-4line %green(%-18X{LOG_ID}) %msg%n</pattern>
|
||||
</layout>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>ERROR</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<root level="ERROR">
|
||||
<appender-ref ref="ERROR_FILE"/>
|
||||
</root>
|
||||
|
||||
<root level="TRACE">
|
||||
<appender-ref ref="TRACE_FILE"/>
|
||||
</root>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT"/>
|
||||
</root>
|
||||
</configuration>
|
Loading…
Reference in New Issue
Block a user