小编Cat*_*ina的帖子

删除所有小于 Elasticsearch 中的值的元素

我在 Elasticsearch 中有以下保存的 json 数据:

   {
   "id":"1234",
   "expirationDate":"17343234234",
   "paths":"http:localhost:9090",
   "work":"software dev",
   "family":{
      "baba":"jams",
      "mother":"ela"
   }
},
{
   "id":"00021",
   "expirationDate":"0123234",
   "paths":"http:localhost:8080",
   "work":"software engi",
   "family":{
      "baba":"stev",
      "mother":"hela"
   }
}
Run Code Online (Sandbox Code Playgroud)

我想在springdata Elasticsearch 中使用 QueryBuilder删除其到期日期小于今天的所有ID列表

java query-builder elasticsearch spring-boot spring-data-elasticsearch

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

所有集成测试完成后是否可以停止重用测试容器

我正在使用单例测试容器来运行多个集成测试,如下所示

    @SpringBootTest(webEnvironment = RANDOM_PORT)
    public abstract class BaseIT {
     
      static final PostgreSQLContainer<?> postgreSQLContainer;
     
      static {
        postgreSQLContainer = 
         new PostgreSQLContainer<>(DockerImageName.parse("postgres:13"))
          .withDatabaseName("test")
          .withUsername("duke")
          .withPassword("s3cret")
          .withReuse(true);
     
        postgreSQLContainer.start();
      }
     
      @DynamicPropertySource
      static void datasourceConfig(DynamicPropertyRegistry registry) {
        registry.add("spring.datasource.url", postgreSQLContainer::getJdbcUrl);
        registry.add("spring.datasource.password", postgreSQLContainer::getPassword);
        registry.add("spring.datasource.username", postgreSQLContainer::getUsername);
      }
    }
Run Code Online (Sandbox Code Playgroud)

然后从测试底座延伸出来

    @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
    class SecondApplicationIT extends BaseIT{
     
      @Autowired
      private TestRestTemplate testRestTemplate;
     
      @Autowired
      private TodoRepository todoRepository;
     
      @AfterEach
      public void cleanup() {
        this.todoRepository.deleteAll();
      }
     
      @Test
      void contextLoads() {
        this.todoRepository.saveAll(List.of(new Todo("Write blog post", LocalDateTime.now().plusDays(2)),
          new Todo("Clean appartment", LocalDateTime.now().plusDays(4))));
     
        ResponseEntity<ArrayNode> result = …
Run Code Online (Sandbox Code Playgroud)

integration-testing spring-boot testcontainers

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

如何在 Spring Boot 中禁用特定标头

是否可以在 Spring Boot 中禁用以下标头?

X-Forwarded-Host: 
X-Host: 
X-Forwarded-Server:
Run Code Online (Sandbox Code Playgroud)

以下对我不起作用

X-Forwarded-Host: 
X-Host: 
X-Forwarded-Server:
Run Code Online (Sandbox Code Playgroud)

header spring-boot

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