小编Mat*_*ene的帖子

在微服务架构中存储文件的正确方法是什么?

我目前正在研究传统的整体应用程序,但是我正在将其分解为由kubernetes管理的春季微服务。该应用程序允许上传/下载大文件,这些文件通常存储在主机文件系统上。我想知道将这些文件保存在微服务体系结构中最可行的方法是什么?

spring persistence docker kubernetes microservices

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

无法自动装配 JobLauncherTestUtils

我正在尝试测试一个简单的 spring 批处理应用程序。

使用 Spring Batch 文档作为指南(在这里找到),我创建了以下测试类:

import org.junit.runner.RunWith;
import org.springframework.batch.test.JobLauncherTestUtils;
import org.springframework.batch.test.context.SpringBatchTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;

import static org.junit.jupiter.api.Assertions.assertNotNull;

@SpringBatchTest
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = BatchConfig.class)
class BatchConfigTest {
    @Autowired
    private JobLauncherTestUtils jobLauncherTestUtils;

    @Test
    void userStep() {
        assertNotNull(jobLauncherTestUtils, "jobLauncherTestUtils should not be null");
    }
}
Run Code Online (Sandbox Code Playgroud)

根据文档@SpringBatchTest应该注入JobLaucherTestUtilsbean。但是,当我运行测试时,断言失败。我还尝试在内部配置类中定义 bean 并得到相同的结果:

    static class TestConfiguration {
        @Autowired
        @Qualifier("userJob")
        private Job userJob;

        @Bean
        public JobLauncherTestUtils jobLauncherTestUtils() {
            JobLauncherTestUtils utils = new JobLauncherTestUtils();
            utils.setJob(userJob);
            return utils;
        }
    }
Run Code Online (Sandbox Code Playgroud)

有什么我想念的吗?完整的源代码可以在 …

junit spring spring-batch

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