我有 2 个作业在基于输入参数的单个 Spring Batch 应用程序中运行,并且运行成功。但是当我运行测试用例时,我收到以下错误。我正在使用 gradle 来构建我的应用程序。
没有“org.springframework.batch.core.Job”类型的合格 bean 可用:预期有单个匹配 bean,但发现 2:pureRedDataProcessingJob、pcsMasterProcessingJob
测试类:
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.test.JobLauncherTestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.ConfigFileApplicationContextInitializer;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
*
* @author
*
*/
@ContextConfiguration(classes = {UidBatchApplication.class, JobLauncherTestUtils.class},
initializers = ConfigFileApplicationContextInitializer.class)
@RunWith(SpringJUnit4ClassRunner.class)
@TestPropertySource(locations = {"classpath:application-test.properties"})
@Configuration
@ActiveProfiles("test")
@Profile("test")
@TestConfiguration
@SpringBootTest
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@EnableAutoConfiguration
public class UidBatchApplicationTest {
@Autowired
public …Run Code Online (Sandbox Code Playgroud) 我修复了我的文件路径,但现在尝试在Eclipse中从java运行shell脚本时出现此错误.
我刚刚在我的本地创建了一个文本文件,想看看它是否会运行.
new ProcessBuilder("C:/Users/myDir/Desktop/ss1.sh").start();
Run Code Online (Sandbox Code Playgroud)