小编nic*_*esh的帖子

在Feign中使用@RequestLine

我有一个工作的Feign接口定义为:

@FeignClient("content-link-service")
public interface ContentLinkServiceClient {

    @RequestMapping(method = RequestMethod.GET, value = "/{trackid}/links")
    List<Link> getLinksForTrack(@PathVariable("trackid") Long trackId);

}
Run Code Online (Sandbox Code Playgroud)

如果我将其更改为使用@RequestLine

@FeignClient("content-link-service")
public interface ContentLinkServiceClient {

    @RequestLine("GET /{trackid}/links")
    List<Link> getLinksForTrack(@Param("trackid") Long trackId);

}
Run Code Online (Sandbox Code Playgroud)

我得到了例外

引起:java.lang.IllegalStateException:方法getLinksForTrack没有使用HTTP方法类型注释(例如GET,POST)

有什么想法吗?

java netflix-feign

12
推荐指数
2
解决办法
1万
查看次数

从 Consul 中删除死服务

我们有许多 Spring Boot 应用程序向 Consul 注册(通过 Spring Cloud Consul)。如果我通过以下方式停止这些应用程序,docker-compose stop myservice那么它们会正确注销自己并从 Consul 中消失。

如果我使用,docker-compose kill myservice则不会发生注销。我知道在 UNIX 系统上不可能捕获 SIGKILL 事件,因此无法强制取消注册。

因此,我们看到的是 Consul 中从未删除的服务(标记为critical但在 UI 中仍然可见)。有没有办法强制 Consul 刷新注册的内容,以便删除死服务?

谢谢

缺口

consul spring-cloud-consul

9
推荐指数
1
解决办法
7633
查看次数

巨大的 org.springframework.boot.loader.LaunchedURLClassLoader 内存使用量

随着时间的推移,我未使用的 Spring Boot v1.3.2 应用程序会逐渐增加内存消耗,直到它最终崩溃。未使用我的意思是除了/health端点的常规 ping 之外,没有为请求的客户端提供服务。

在此处输入图片说明

根据 Eclipse Memory Analyser 的说法,org.springframework.boot.loader.LaunchedURLClassLoader它占用了 920MB 的大量空间。

在此处输入图片说明

似乎 Spring Boot 正在不断加载类

在此处输入图片说明

任何想法发生了什么?

编辑

看起来是 Spring Cloud Consul 导致了这个问题:

在此处输入图片说明

spring-boot spring-cloud

7
推荐指数
1
解决办法
3723
查看次数

Spring 集成测试中未注入自定义过滤器

我有一个集成测试,旨在启动我的 Spring Boot 应用程序:

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = AppConfigCorrelationIdTestIt.class)
@WebIntegrationTest("server.port:0")
public class CorrelationIdTestIT {
Run Code Online (Sandbox Code Playgroud)

配置类在哪里:

@EnableConfigurationProperties
@ComponentScan
@EnableAutoConfiguration
@Configuration
public class AppConfigCorrelationIdTestIt {
Run Code Online (Sandbox Code Playgroud)

在应用程序中,我有一个定义的自定义 servlet 过滤器:

public class CorrelationHeaderFilter implements Filter {
Run Code Online (Sandbox Code Playgroud)

但是在测试我的应用程序时,我发现客户过滤器没有被实例化并注入到过滤器链中。我发现解决此问题的唯一方法是手动将其创建为 中的 bean AppConfigCorrelationIdTestIt,然后它就可以完美运行。

@Bean
public CorrelationHeaderFilter correlationHeaderFilter() {
    return new CorrelationHeaderFilter();
}
Run Code Online (Sandbox Code Playgroud)

任何想法为什么在应用程序启动时 Spring Boot 没有选择过滤器?

谢谢

spring integration-testing filter

5
推荐指数
1
解决办法
3568
查看次数

混沌猴等同于Docker?

是否有像Chaos Monkey这样的工具会随机关闭docker容器,所以我们可以测试系统的弹性?

docker

5
推荐指数
2
解决办法
1997
查看次数

声纳抱怨“ SonarQube分析已经在进行中”

我正在尝试通过Maven运行Sonar分析,但它一直在抱怨:

[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.7.1:sonar (default-cli) on project mio-commons: Another SonarQube analysis is already in progress for this project -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
Run Code Online (Sandbox Code Playgroud)

此项目尚无任何分析,我什至尝试从Sonar中删除项目本身。任何想法可能是什么问题?

sonarqube

1
推荐指数
3
解决办法
3274
查看次数