浏览代码

新增断路器

chenweida 7 年之前
父节点
当前提交
f141162aa5

+ 1 - 0
readme.MD

@ -5,6 +5,7 @@
        svr-user 用户微服务
     svr-configuration    配置服务
     svr-discovery    发现服务
     svr-dashboard    监控服务
     common-lib-parent-pom    common公共工程的maven父pom
     jw-lib-parent-pom   jw业务公共工程的maven父pom
     web-gateway 对外的接口网关

+ 5 - 4
svr-configuration/src/main/resources/application.yml

@ -1,4 +1,5 @@
server:
  port: 1221
##配置服务的账号密码
security:
@ -9,7 +10,7 @@ security:
---
spring:
  profiles: dev
  profiles: jwdev
eureka:
  client:
@ -19,7 +20,7 @@ eureka:
---
spring:
  profiles: test
  profiles: jwtest
eureka:
  client:
@ -28,7 +29,7 @@ eureka:
---
spring:
  profiles: prod
  profiles: jwprod
eureka:

+ 3 - 3
svr-configuration/src/main/resources/bootstrap.yml

@ -5,7 +5,7 @@ spring:
---
spring:
  profiles: dev
  profiles: jwdev
##git配置
  cloud:
    config:
@ -17,7 +17,7 @@ spring:
---
spring:
  profiles: test
  profiles: jwtest
##git配置
  cloud:
    config:
@ -28,7 +28,7 @@ spring:
---
spring:
  profiles: prod
  profiles: jwprod
##git配置
  cloud:
    config:

+ 69 - 0
svr-dashboard/pom.xml

@ -0,0 +1,69 @@
<?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.yihu.jw</groupId>
        <artifactId>svr-lib-parent-pom</artifactId>
        <version>1.0.0</version>
        <relativePath>../svr-lib-parent-pom/pom.xml</relativePath>
    </parent>
    <groupId>com.yihu.jw</groupId>
    <artifactId>svr-dashboard</artifactId>
    <version>1.0-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</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-config</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-feign</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-hystrix</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-netflix-hystrix-dashboard</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-zuul</artifactId>
        </dependency>
    </dependencies>
</project>

+ 26 - 0
svr-dashboard/src/main/java/com/yihu/jw/DashboardApplication.java

@ -0,0 +1,26 @@
package com.yihu.jw;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
/**
 * Created by chenweida on 2017/5/16.
 */
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class})
//@SpringBootApplication
@EnableDiscoveryClient//服务注册到发现服务
@EnableHystrixDashboard //启动Hystrix仪表盘(监控数据)
@EnableFeignClients //声名式的客户端
public class DashboardApplication {
    public static void main(String[] args) {
        SpringApplication.run(DashboardApplication.class, args);
    }
}

+ 39 - 0
svr-dashboard/src/main/resources/application.yml

@ -0,0 +1,39 @@
##如果有配置服务的话,远程服务器和本地服务器配置不一致的情况下,优先远程的为主
spring:
  application:
    name:  svr-dashboard  ##注册到发现服务的id 如果id一样 eurika会自动做负载
---
spring:
  profiles: jwdev
eureka:
  client:
    serviceUrl:
      #http://账号:密码@127.0.0.1:8761/eureka/
      defaultZone: http://jw:jkzl@127.0.0.1:8761/eureka/
---
spring:
  profiles: jwtest
eureka:
  client:
    serviceUrl:
      #http://账号:密码@127.0.0.1:8761/eureka/
      defaultZone: http://jw:jkzl@127.0.0.1:8761/eureka/
---
spring:
  profiles: jwprod
eureka:
  client:
    serviceUrl:
      #http://账号:密码@127.0.0.1:8761/eureka/
      defaultZone: http://jw:jkzl@127.0.0.1:8761/eureka/

+ 6 - 0
svr-dashboard/src/main/resources/banner.txt

@ -0,0 +1,6 @@
 _____              _____            _     _                         _
  / ____|            |  __ \          | |   | |                       | |
 | (_____   ___ __   | |  | | __ _ ___| |__ | |__   ___   __ _ _ __ __| |
  \___ \ \ / / '__|  | |  | |/ _` / __| '_ \| '_ \ / _ \ / _` | '__/ _` |
  ____) \ V /| |     | |__| | (_| \__ \ | | | |_) | (_) | (_| | | | (_| |
 |_____/ \_/ |_|     |_____/ \__,_|___/_| |_|_.__/ \___/ \__,_|_|  \__,_|

+ 3 - 3
svr-discovery/src/main/resources/application.yml

@ -24,12 +24,12 @@ security:
---
spring:
  profiles: dev
  profiles: jwdev
---
spring:
  profiles: test
  profiles: jwtest
---
spring:
  profiles: prod
  profiles: jwprod

+ 6 - 6
svr/svr-base/src/main/resources/banner.txt

@ -1,6 +1,6 @@
  _____               _    _
  / ____|             | |  | |
 | (_____   ___ __    | |  | |___  ___ _ __
  \___ \ \ / / '__|   | |  | / __|/ _ \ '__|
  ____) \ V /| |      | |__| \__ \  __/ |
 |_____/ \_/ |_|       \____/|___/\___|_|
   _____              ____
  / ____|            |  _ \
 | (_____   ___ __   | |_) | __ _ ___  ___
  \___ \ \ / / '__|  |  _ < / _` / __|/ _ \
  ____) \ V /| |     | |_) | (_| \__ \  __/
 |_____/ \_/ |_|     |____/ \__,_|___/\___|

+ 1 - 5
web-gateway/pom.xml

@ -65,11 +65,7 @@
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-netflix-hystrix-dashboard</artifactId>
            <artifactId>spring-cloud-starter-zuul</artifactId>
        </dependency>
        <!--<dependency>-->
            <!--<groupId>org.springframework.cloud</groupId>-->
            <!--<artifactId>spring-cloud-starter-zuul</artifactId>-->
        <!--</dependency>-->
    </dependencies>
</project>

+ 1 - 6
web-gateway/src/main/java/com/yihu/jw/WebGateWayAppliaction.java

@ -1,19 +1,15 @@
package com.yihu.jw;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;
/**
 * Created by chenweida on 2017/5/10.
@ -22,8 +18,7 @@ import org.springframework.web.client.RestTemplate;
//@SpringBootApplication
@EnableDiscoveryClient//服务注册到发现服务
@EnableHystrix //启动断路器
@EnableHystrixDashboard //启动Hystrix仪表盘(监控数据)
//@EnableZuulProxy //启动zuul代理 路由
@EnableZuulProxy //启动zuul代理 路由
@EnableFeignClients //声名式的客户端
@EnableCircuitBreaker
public class WebGateWayAppliaction {

+ 3 - 3
web-gateway/src/main/resources/application.yml

@ -33,12 +33,12 @@ zuul:
---
spring:
  profiles: dev
  profiles: jwdev
---
spring:
  profiles: test
  profiles: jwtest
---
spring:
  profiles: prod
  profiles: jwprod

+ 3 - 3
web-gateway/src/main/resources/bootstrap.yml

@ -12,7 +12,7 @@ spring:
---
spring:
  profiles: dev
  profiles: jwdev
eureka:
@ -23,7 +23,7 @@ eureka:
---
spring:
  profiles: test
  profiles: jwtest
eureka:
@ -35,7 +35,7 @@ eureka:
---
spring:
  profiles: prod
  profiles: jwprod
eureka: