我在 Spring boot 1.5.9 中使用 Springfox Swagger2。
我可以在此链接上访问 swagger UI。
http://localhost:8090/swagger-ui.html
如何将其更改为在以下 URL 上可用?
http://localhost:8090/my/custom/path/swagger-ui.html
@EnableSwagger2
public class Configuration {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("my.favorite.package"))
.paths(PathSelectors.any())
.build()
.apiInfo(apiInfo()).useDefaultResponseMessages(false);
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder().title("My title").version("1.0")
.contact(new Contact("Blah", "blah.com", "blah@blah.com")).build();
}
}
Run Code Online (Sandbox Code Playgroud) 我的项目中有以下代码
@HystrixCommand(groupKey = "AddressRepository", commandKey =
"getAddressById", threadPoolKey = "addressSearchPool")
public List<Address> getAddressById(String id)
throws MyCustomException, HystrixRuntimeException {
try (Connection con = sql2o.open()) {
return // some logic....
} catch (Sql2oException e) {
throw new MyCustomException();
}
}
Run Code Online (Sandbox Code Playgroud)
如您所见,@HystrixCommand 没有定义任何 fallbackMethod。我想知道 HystrixCommand 在这里服务的目的是什么。
当没有定义回退时,使用 HystrixCommand 的用例是什么?
代码是 Spring 应用程序的一部分。
我在prod环境中看到一些异常行为导致我们在运行Tomcat的服务器上出现高线程数.堆大小10,092,544K在新一代和产权生成之间分配为2,752,512K + 7,340,032K = 10,092,544K.
我很困惑为什么GC在堆上有足够的内存可用时多次运行(新旧两种)(Full GC [PSYoungGen:0K-> 0K(2752512K)] [ParOldGen:2748534K-> 2748529K(7340032K) )])
正如你可以看到0K-> 0K的年轻人和.27G - > .27G的老一代意味着几乎没有任何对象得到gc'd并且有很多可用的内存.(堆大小为10G).
由于Full GC在短时间间隔内运行多次,因此导致性能降低,因此应用程序无法处理传入的用户请求,因此无法处理服务器上的高线程,最终我们必须重新启动服务器以摆脱这种情况.
你能解释一下这里发生了什么.
这是gc.log上的输出.
..
更多...... ..
7月18日14:52:38 fwprodcontent03 gc.log:3172.122:[GC [PSYoungGen:0K-> 0K(2752512K)] 2750855K-> 2750855K(10092544K),0.0515920 secs] [次:用户= 0.32 sys = 0.01,real = 0.06秒]
7月18日14:52:42 fwprodcontent03 gc.log:3172.174:[Full GC [PSYoungGen:0K-> 0K(2752512K)] [ParOldGen:2750855K-> 2749937K(7340032K)] 2750855K-> 2749937K(10092544K)[PSPermGen:262143K - > 262115K(262144K)],4.1571260秒] [时间:用户= 44.29 sys = 0.06,实际= 4.15秒]
7月18日14:52:42 fwprodcontent03 gc.log:3176.361:[GC [PSYoungGen:9071K-> 1280K(2752512K)] 2759008K-> 2751217K(10092544K),0.0989600 secs] [次:用户= 0.64 sys = 0.01,real = 0.10秒]
7月18日14:52:46 fwprodcontent03 gc.log:3176.461:[全GC [PSYoungGen:1280K-> 0K(2752512K)] [ParOldGen:2749937K-> 2748847K(7340032K)] …
java ×2
hystrix ×1
jvm ×1
memory-leaks ×1
spring ×1
spring-boot ×1
swagger ×1
swagger-2.0 ×1
swagger-ui ×1