文章目录
- 1.环境搭建
- 1.创建sunrays-common-cloud-gateway-starter模块
- 2.目录结构
- 3.自动配置
- 1.GateWayAutoConfiguration.java
- 2.spring.factories
- 3.pom.xml
- 4.注意:GateWay不能跟Web一起引入!
1.环境搭建
1.创建sunrays-common-cloud-gateway-starter模块
2.目录结构
3.自动配置
1.GateWayAutoConfiguration.java
package com.sunxiansheng.cloud.gateway.config;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import javax.annotation.PostConstruct;
@Slf4j
@Configuration
public class GateWayAutoConfiguration {
@PostConstruct
public void logConfigSuccess() {
log.info("GateWayAutoConfiguration has been loaded successfully!");
}
}
2.spring.factories
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.sunxiansheng.cloud.gateway.config.GateWayAutoConfiguration
3.pom.xml
<?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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.sunxiansheng</groupId>
<artifactId>sunrays-common-cloud</artifactId>
<version>2.0.0</version>
</parent>
<artifactId>sunrays-common-cloud-gateway-starter</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
<exclusions>
<exclusion>
<artifactId>spring-boot-starter-logging</artifactId>
<groupId>org.springframework.boot</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-loadbalancer</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
</dependencies>
</project>
4.注意:GateWay不能跟Web一起引入!