考虑以下代码:
@RestController
@RequestMapping("/timeout")
public class TestController {
@Autowired
private TestService service;
@GetMapping("/max10secs")
public String max10secs() {
//In some cases it can take more than 10 seconds
return service.call();
}
}
@Service
public class TestService {
public String call() {
//some business logic here
return response;
}
}
Run Code Online (Sandbox Code Playgroud)
我想要完成的是,如果call来自的方法TestService需要超过 10 秒,我想取消它并使用HttpStatus.REQUEST_TIMEOUT代码生成响应。
spring request-timed-out spring-boot spring-restcontroller spring-async
我已经实现了一个小示例项目来说明我遇到的问题。它位于这里:
https://github.com/jvillane/spring-boot-hateoas-rest
Run Code Online (Sandbox Code Playgroud)
我想要做的是创建同一个实体的几个@Projection:
https://github.com/jvillane/spring-boot-hateoas-rest
Run Code Online (Sandbox Code Playgroud)
并使用它们通过调用(带引号和不带引号)来获取或多或少的实体信息:
@Projection(name = "S", types = User.class)
public interface UserS {
String getName();
}
@Projection(name = "M", types = User.class)
public interface UserM {
String getName();
String getDni();
}
@Projection(name = "L", types = User.class)
public interface UserL {
String getName();
String getDni();
Country getCountry();
}
Run Code Online (Sandbox Code Playgroud)
但这对响应没有影响,就像使用默认方式显示实体信息一样。
我不知道我做错了什么。欢迎任何帮助。
有谁知道如何在 Datagrip 中配置 Netezza 数据库连接?
是否可以?也许不是。
提前致谢!