diff --git a/backend/microservice-gateway/pom.xml b/backend/microservice-gateway/pom.xml index 75c2848..296aaa7 100644 --- a/backend/microservice-gateway/pom.xml +++ b/backend/microservice-gateway/pom.xml @@ -23,6 +23,27 @@ junit test + + org.springframework.cloud + spring-cloud-starter-gateway + + + org.springframework.cloud + spring-cloud-starter-loadbalancer + + + + ch.qos.logback + logback-core + + + org.slf4j + slf4j-api + + + org.slf4j + slf4j-simple + diff --git a/backend/microservice-gateway/src/main/java/com/cxyxiaomo/App.java b/backend/microservice-gateway/src/main/java/com/cxyxiaomo/App.java deleted file mode 100644 index 796b015..0000000 --- a/backend/microservice-gateway/src/main/java/com/cxyxiaomo/App.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.cxyxiaomo; - -/** - * Hello world! - * - */ -public class App -{ - public static void main( String[] args ) - { - System.out.println( "Hello World!" ); - } -} diff --git a/backend/microservice-gateway/src/main/java/com/cxyxiaomo/epp/Gateway.java b/backend/microservice-gateway/src/main/java/com/cxyxiaomo/epp/Gateway.java new file mode 100644 index 0000000..6157933 --- /dev/null +++ b/backend/microservice-gateway/src/main/java/com/cxyxiaomo/epp/Gateway.java @@ -0,0 +1,12 @@ +package com.cxyxiaomo.epp; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Gateway { + public static void main(String[] args) { + SpringApplication.run(Gateway.class, args); + } +} + diff --git a/backend/microservice-gateway/src/main/resources/application.yml b/backend/microservice-gateway/src/main/resources/application.yml new file mode 100644 index 0000000..dc1d61d --- /dev/null +++ b/backend/microservice-gateway/src/main/resources/application.yml @@ -0,0 +1,18 @@ +server: + port: 80 + +# Spring 配置 +spring: + application: + name: microservice-gateway + cloud: + gateway: + discovery: + locator: + enabled: true + lower-case-service-id: true + routes: + - id: test + uri: lb://microservice-provider-test-8011 + predicates: + - Path=/test/** diff --git a/backend/microservice-gateway/src/test/java/com/cxyxiaomo/AppTest.java b/backend/microservice-gateway/src/test/java/com/cxyxiaomo/AppTest.java deleted file mode 100644 index ef44881..0000000 --- a/backend/microservice-gateway/src/test/java/com/cxyxiaomo/AppTest.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.cxyxiaomo; - -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -/** - * Unit test for simple App. - */ -public class AppTest -{ - /** - * Rigorous Test :-) - */ - @Test - public void shouldAnswerWithTrue() - { - assertTrue( true ); - } -} diff --git a/backend/microservice-provider-test-8011/src/test/java/com/cxyxiaomo/epp/AppTest.java b/backend/microservice-gateway/src/test/java/com/cxyxiaomo/epp/GatewayTest.java similarity index 91% rename from backend/microservice-provider-test-8011/src/test/java/com/cxyxiaomo/epp/AppTest.java rename to backend/microservice-gateway/src/test/java/com/cxyxiaomo/epp/GatewayTest.java index b3dda20..61aea9e 100644 --- a/backend/microservice-provider-test-8011/src/test/java/com/cxyxiaomo/epp/AppTest.java +++ b/backend/microservice-gateway/src/test/java/com/cxyxiaomo/epp/GatewayTest.java @@ -7,7 +7,7 @@ import org.junit.Test; /** * Unit test for simple App. */ -public class AppTest +public class GatewayTest { /** * Rigorous Test :-) diff --git a/backend/microservice-provider-test-8011/pom.xml b/backend/microservice-provider-test-8011/pom.xml index cf03d61..065b99f 100644 --- a/backend/microservice-provider-test-8011/pom.xml +++ b/backend/microservice-provider-test-8011/pom.xml @@ -27,5 +27,18 @@ org.springframework.boot spring-boot-starter-web + + + ch.qos.logback + logback-core + + + org.slf4j + slf4j-api + + + org.slf4j + slf4j-simple + diff --git a/backend/pom.xml b/backend/pom.xml index 97ce6ca..2cfc762 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -46,6 +46,18 @@ pom import + + + org.springframework.cloud + spring-cloud-starter-gateway + 3.1.4 + + + + org.springframework.cloud + spring-cloud-starter-loadbalancer + 3.1.4 + org.springframework.boot