小编Jul*_*ane的帖子

在@RestController 中限制时间执行的最佳方法

考虑以下代码:

@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

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

@Projection 不起作用

我已经实现了一个小示例项目来说明我遇到的问题。它位于这里:

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)

但这对响应没有影响,就像使用默认方式显示实体信息一样。

我不知道我做错了什么。欢迎任何帮助。

java spring-data-rest spring-hateoas spring-boot

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

如何在 Datagrip 中配置 Netezza?

有谁知道如何在 Datagrip 中配置 Netezza 数据库连接?

是否可以?也许不是。

提前致谢!

jdbc netezza datagrip

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