diff --git a/api-gateway/.gitignore b/api-gateway/.gitignore new file mode 100644 index 0000000..a2a3040 --- /dev/null +++ b/api-gateway/.gitignore @@ -0,0 +1,31 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/** +!**/src/test/** + +### 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/ + +### VS Code ### +.vscode/ diff --git a/api-gateway/pom.xml b/api-gateway/pom.xml new file mode 100644 index 0000000..3a48333 --- /dev/null +++ b/api-gateway/pom.xml @@ -0,0 +1,64 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.0.2.RELEASE + + + cn.algerfan + api-gateway + 0.0.1-SNAPSHOT + api-gateway + Demo project for Spring Boot + + + 1.8 + Finchley.RELEASE + + + + + org.springframework.cloud + spring-cloud-starter-config + + + org.springframework.cloud + spring-cloud-starter-netflix-eureka-client + + + org.springframework.cloud + spring-cloud-starter-netflix-zuul + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/api-gateway/src/main/java/cn/algerfan/apigateway/ApiGatewayApplication.java b/api-gateway/src/main/java/cn/algerfan/apigateway/ApiGatewayApplication.java new file mode 100644 index 0000000..f9f1462 --- /dev/null +++ b/api-gateway/src/main/java/cn/algerfan/apigateway/ApiGatewayApplication.java @@ -0,0 +1,18 @@ +package cn.algerfan.apigateway; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.netflix.zuul.EnableZuulProxy; + +/** + * @author algerfan + */ +@SpringBootApplication +@EnableZuulProxy +public class ApiGatewayApplication { + + public static void main(String[] args) { + SpringApplication.run(ApiGatewayApplication.class, args); + } + +} diff --git a/api-gateway/src/main/java/cn/algerfan/apigateway/ZuulConfig.java b/api-gateway/src/main/java/cn/algerfan/apigateway/ZuulConfig.java new file mode 100644 index 0000000..f785d84 --- /dev/null +++ b/api-gateway/src/main/java/cn/algerfan/apigateway/ZuulConfig.java @@ -0,0 +1,21 @@ +package cn.algerfan.apigateway; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.cloud.context.config.annotation.RefreshScope; +import org.springframework.cloud.netflix.zuul.filters.ZuulProperties; +import org.springframework.stereotype.Component; + +/** + * @author algerfan + * @time 2019/8/27 20:46 + */ +@Component +public class ZuulConfig { + + @ConfigurationProperties("zuul") + @RefreshScope + public ZuulProperties zuulProperties(){ + return new ZuulProperties(); + } + +} diff --git a/api-gateway/src/main/resources/bootstrap.yml b/api-gateway/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..62af3a1 --- /dev/null +++ b/api-gateway/src/main/resources/bootstrap.yml @@ -0,0 +1,15 @@ +eureka: + client: + service-url: + defaultZone: http://127.0.0.1:8761/eureka/ + instance: + prefer-ip-address: true +spring: + application: + name: api-gateway + cloud: + config: + discovery: + enabled: true + service-id: CONFIG + profile: dev diff --git a/api-gateway/src/test/java/cn/algerfan/apigateway/ApiGatewayApplicationTests.java b/api-gateway/src/test/java/cn/algerfan/apigateway/ApiGatewayApplicationTests.java new file mode 100644 index 0000000..8a4c6d4 --- /dev/null +++ b/api-gateway/src/test/java/cn/algerfan/apigateway/ApiGatewayApplicationTests.java @@ -0,0 +1,16 @@ +package cn.algerfan.apigateway; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class ApiGatewayApplicationTests { + + @Test + public void contextLoads() { + } + +} diff --git a/eureka/pom.xml b/eureka/pom.xml index 22ca695..0a846bf 100755 --- a/eureka/pom.xml +++ b/eureka/pom.xml @@ -5,7 +5,6 @@ org.springframework.boot spring-boot-starter-parent - 2.0.2.RELEASE @@ -17,7 +16,6 @@ 1.8 - Finchley.RELEASE @@ -54,43 +52,5 @@ - - - - + diff --git a/order/order-server/pom.xml b/order/order-server/pom.xml index c1886fb..8b717fe 100644 --- a/order/order-server/pom.xml +++ b/order/order-server/pom.xml @@ -16,7 +16,6 @@ org.springframework.cloud spring-cloud-starter-netflix-eureka-client - org.springframework.cloud spring-cloud-starter-openfeign @@ -37,8 +36,8 @@ org.springframework.boot spring-boot-starter-data-redis - - + + org.springframework.boot spring-boot-starter-web diff --git a/order/pom.xml b/order/pom.xml index b908cde..9459919 100755 --- a/order/pom.xml +++ b/order/pom.xml @@ -10,7 +10,6 @@ org.springframework.boot spring-boot-starter-parent - 2.0.2.RELEASE @@ -23,7 +22,6 @@ 1.8 - Finchley.RELEASE 0.0.1-SNAPSHOT 0.0.1-SNAPSHOT @@ -41,41 +39,4 @@ - - diff --git a/product/pom.xml b/product/pom.xml index 8a3d93e..37f68fe 100755 --- a/product/pom.xml +++ b/product/pom.xml @@ -10,7 +10,6 @@ org.springframework.boot spring-boot-starter-parent - 2.0.2.RELEASE @@ -23,7 +22,6 @@ 1.8 - Finchley.RELEASE @@ -39,42 +37,4 @@ - - - diff --git a/product/product-server/pom.xml b/product/product-server/pom.xml index 7ef7086..ab07b33 100644 --- a/product/product-server/pom.xml +++ b/product/product-server/pom.xml @@ -28,7 +28,7 @@ org.springframework.cloud spring-cloud-starter-bus-amqp - + org.springframework.boot spring-boot-starter-web