Forráskód Böngészése

add spring cloud example

zhouhao 7 éve
szülő
commit
2a7b3d8507

+ 40 - 0
hsweb-examples/hsweb-examples-cloud/hsweb-examples-cloud-gateway/pom.xml

@@ -0,0 +1,40 @@
+<?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">
+    <parent>
+        <artifactId>hsweb-examples-cloud</artifactId>
+        <groupId>org.hswebframework.web</groupId>
+        <version>3.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>hsweb-examples-cloud-gateway</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-config</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-eureka-server</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-eureka</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-zuul</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-logging</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-classic</artifactId>
+        </dependency>
+    </dependencies>
+</project>

+ 15 - 0
hsweb-examples/hsweb-examples-cloud/hsweb-examples-cloud-gateway/src/main/java/org/hswebframework/web/examples/cloud/gateway/Application.java

@@ -0,0 +1,15 @@
+package org.hswebframework.web.examples.cloud.gateway;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.cloud.client.SpringCloudApplication;
+import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
+import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
+
+@SpringCloudApplication
+@EnableEurekaServer
+@EnableZuulProxy
+public class Application {
+    public static void main(String[] args) {
+        SpringApplication.run(Application.class, args);
+    }
+}

+ 23 - 0
hsweb-examples/hsweb-examples-cloud/hsweb-examples-cloud-gateway/src/main/resources/application.yml

@@ -0,0 +1,23 @@
+server:
+  compression:
+    enabled: true
+  port: 8761
+eureka:
+  client:
+    register-with-eureka: true
+    fetch-registry: true
+zuul:
+  prefix: /api
+  routes:
+    user-center:
+      path: /user-center/**
+      service-id: user-center
+ribbon:
+  eureka:
+    enabled: true
+spring:
+  application:
+    name: gateway
+#user-center:
+#  ribbon:
+#    listOfServers: 127.0.0.1:9001

+ 61 - 0
hsweb-examples/hsweb-examples-cloud/hsweb-examples-cloud-user-center/pom.xml

@@ -0,0 +1,61 @@
+<?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">
+    <parent>
+        <artifactId>hsweb-examples-cloud</artifactId>
+        <groupId>org.hswebframework.web</groupId>
+        <version>3.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>hsweb-examples-cloud-user-center</artifactId>
+
+
+    <dependencies>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>druid</artifactId>
+            <version>1.0.26</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.hswebframework.web</groupId>
+            <artifactId>hsweb-spring-boot-starter</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.hswebframework.web</groupId>
+            <artifactId>hsweb-system-authorization-starter</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-logging</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.hswebframework.web</groupId>
+            <artifactId>hsweb-spring-boot-starter</artifactId>
+            <version>3.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-eureka</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-hystrix</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-classic</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.h2database</groupId>
+            <artifactId>h2</artifactId>
+        </dependency>
+    </dependencies>
+</project>

+ 19 - 0
hsweb-examples/hsweb-examples-cloud/hsweb-examples-cloud-user-center/src/main/java/org/hswebframework/web/examples/cloud/user/InfoController.java

@@ -0,0 +1,19 @@
+package org.hswebframework.web.examples.cloud.user;
+
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * TODO 完成注释
+ *
+ * @author zhouhao
+ * @since
+ */
+@RestController
+public class InfoController {
+
+    @GetMapping("/info")
+    public String info() {
+        return "success";
+    }
+}

+ 15 - 0
hsweb-examples/hsweb-examples-cloud/hsweb-examples-cloud-user-center/src/main/java/org/hswebframework/web/examples/cloud/user/UserCenterApplication.java

@@ -0,0 +1,15 @@
+package org.hswebframework.web.examples.cloud.user;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.netflix.hystrix.EnableHystrix;
+
+@SpringBootApplication
+@EnableDiscoveryClient
+@EnableHystrix
+public class UserCenterApplication {
+    public static void main(String[] args) {
+        SpringApplication.run(UserCenterApplication.class, args);
+    }
+}

+ 18 - 0
hsweb-examples/hsweb-examples-cloud/hsweb-examples-cloud-user-center/src/main/resources/application.yml

@@ -0,0 +1,18 @@
+spring:
+  aop:
+      auto: true
+  datasource:
+     url : jdbc:h2:mem:permission_test_mem
+     username : sa
+     password :
+     type: com.alibaba.druid.pool.DruidDataSource
+     driver-class-name : org.h2.Driver
+hsweb:
+    app:
+      name: 权限管理测试
+      version: 3.0.0
+server:
+    port: 9002
+logging:
+  level:
+    org.hswebframework.web: debug

+ 9 - 0
hsweb-examples/hsweb-examples-cloud/hsweb-examples-cloud-user-center/src/main/resources/bootstrap.yml

@@ -0,0 +1,9 @@
+spring:
+  application:
+    name: user-center
+  cloud:
+    discovery:
+      client:
+        simple:
+          local:
+            service-id: user-center

+ 30 - 0
hsweb-examples/hsweb-examples-cloud/pom.xml

@@ -0,0 +1,30 @@
+<?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">
+    <parent>
+        <artifactId>hsweb-examples</artifactId>
+        <groupId>org.hswebframework.web</groupId>
+        <version>3.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>hsweb-examples-cloud</artifactId>
+    <packaging>pom</packaging>
+    <modules>
+        <module>hsweb-examples-cloud-gateway</module>
+        <module>hsweb-examples-cloud-user-center</module>
+    </modules>
+
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.springframework.cloud</groupId>
+                <artifactId>spring-cloud-dependencies</artifactId>
+                <version>Dalston.SR4</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+</project>