【发布时间】:2018-07-16 10:12:06
【问题描述】:
我有以下测试类,我的 bean 总是根据我的 src 路径中的 application.properties 自动装配。
简单属性已正确自动装配(queueFrom、queueTo...),但属性 camelContext 与主体 application.properties 文件自动装配
我想用 测试路径
中的特定属性文件自动装配我的 bean这是我的测试类的标题:
@RunWith(CamelSpringBootRunner.class)
@SpringBootTest
@EnableAutoConfiguration
@TestPropertySource(locations = "classpath:application-north-connector-test.properties")
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
public class LifeRouteITTest extends CamelTestSupport {
private NotifyBuilder notify;
@Value("${route.lifefrom}")
private String queueFrom;
@Value("${route.lifeto}")
private String queueTo;
@Value("${expected.liferoute.file.path}/")
private String expectedFilePath;
@Value("${input.liferoute.file.path}/")
private String inputFilePath;
@Autowired
private CamelContext camelContext;
}
感谢您的帮助。
【问题讨论】:
-
Spring boot 在 src/main/resources 下查找 application.properties。对于测试,它的 src/test/resources. Spring boot 会自动从这些位置获取文件。
标签: java spring spring-boot properties-file spring-camel