github上Webhook配置的/monitor问题不起作用
来源:6-6 集成WebHooks实现动态更新
慕仙4974986
2018-06-04
配置方式都是跟老师的一模一样,
http://43in8i.natappfree.cc/actuator/bus-refresh
用这个链接刷新是OK的但是在Github上配置
http://43in8i.natappfree.cc/monitor
就不行
上面两张图是github的webhooks 的请求记录。
8回答
-
同学你好,我们现在做问题回访,请你的问题最后得到了解决吗?
082018-08-04 -
十年一觉梦方醒
2018-07-08
9. Push Notifications and Spring Cloud Bus
Many source code repository providers (such as Github, Gitlab, Gitee, or Bitbucket) notify you of changes in a repository through a webhook. You can configure the webhook through the provider’s user interface as a URL and a set of events in which you are interested. For instance, Github uses a POST to the webhook with a JSON body containing a list of commits and a header (X-Github-Event) set to push. If you add a dependency on the spring-cloud-config-monitor library and activate the Spring Cloud Bus in your Config Server, then a /monitor endpoint is enabled.
When the webhook is activated, the Config Server sends a RefreshRemoteApplicationEvent targeted at the applications it thinks might have changed. The change detection can be strategized. However, by default, it looks for changes in files that match the application name (for example, foo.properties is targeted at the fooapplication, while application.properties is targeted at all applications). The strategy to use when you want to override the behavior is PropertyPathNotificationExtractor, which accepts the request headers and body as parameters and returns a list of file paths that changed.
The default configuration works out of the box with Github, Gitlab, Gitee, or Bitbucket. In addition to the JSON notifications from Github, Gitlab, Gitee, or Bitbucket, you can trigger a change notification by POSTing to /monitor with form-encoded body parameters in the pattern of path={name}. Doing so broadcasts to applications matching the {name} pattern (which can contain wildcards).
上面是官方文档的说明,请注意带下划线的部分。言下之意就是会根据配置文件的名字来匹配应用的名字。如果git上有order.yml, order-dev.yml 两个配置文件,那么修改order-dev.yml文件时不能刷新config-client的配置,因为无法找到order-dev这么一个注册的服务。 但修改order.yml时,则会刷新config-client(即注册的order服务)。
结论就是要想让webhook里配置的/monitor方式对config-client起作用,修改{ApplicationName}.yml文件即可。 修改{ApplicationName}-{profile}这样的配置文件,是不行的。
432018-11-27 -
hellozjf
2018-08-03
开启spring-cloud-config-monitor之后也不行,因为这是spring cloud bus的一个bug,详见https://github.com/spring-cloud/spring-cloud-bus/issues/124
00 -
十年一觉梦方醒
2018-07-08
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-monitor</artifactId>
</dependency>在config-server的配置文件中加上这个依赖就可以开放/monitor接口的访问了
022019-05-18 -
张小泰
2018-07-02
我也正有此疑问,为什么在给oschina 使用 actuator/bus-refresh 做演示 ,到github就是变成/monitor,我用postman 试过本地去吊用 monitor 也是404
00 -
黑鹰2
2018-06-29
补充:
application.yml如下:
spring: application: name: config cloud: bus: trace: enabled: true config: server: git: uri: https://github.com/xyang0917/springcloud-config username: xyang0917@gmail.com password: xxxxx basedir: /Users/yangxin/Documents/project/Java/springcloud/config/repository eureka: client: service-url: defaultZone: http://localhost:8762/eureka/ management: endpoints: web: exposure: include: "*"
00 -
黑鹰2
2018-06-29
我也遇到了同样的问题,/monitor接口不能访问。Config Server好像没有开启/monitor接口
下面是Config Server的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> <groupId>com.yangxin</groupId> <artifactId>config</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>config</name> <description>Demo project for Spring Boot</description> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <!--<version>2.0.0.M3</version>--> <version>2.0.0.BUILD-SNAPSHOT</version> <relativePath/> <!-- lookup parent from repository --> </parent> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> <spring-cloud.version>Finchley.BUILD-SNAPSHOT</spring-cloud.version> </properties> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-config-server</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-bus-amqp</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>${spring-cloud.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> <repositories> <repository> <id>spring-snapshots</id> <name>Spring Snapshots</name> <url>https://repo.spring.io/snapshot</url> <snapshots> <enabled>true</enabled> </snapshots> </repository> <repository> <id>spring-milestones</id> <name>Spring Milestones</name> <url>https://repo.spring.io/milestone</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>spring-snapshots</id> <name>Spring Snapshots</name> <url>https://repo.spring.io/snapshot</url> <snapshots> <enabled>true</enabled> </snapshots> </pluginRepository> <pluginRepository> <id>spring-milestones</id> <name>Spring Milestones</name> <url>https://repo.spring.io/milestone</url> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> </pluginRepositories> </project>
00 -
wirechen
2018-06-05
你在gitee上试过吗?然后你本地能访问,github却报404会不会你那个穿透的隧道国外网络访问不了?
032018-07-04
SpringCloud Finchley(M2+RELEASE+SR2)微服务实战
5668 学习 · 2489 问题
相似问题
回答 1