簡體   English   中英

在Junit測試中無法覆蓋Spring-Boot應用程序屬性

[英]Cannot overrid Spring-Boot application properties in Junit Test

我正在嘗試覆蓋應用程序屬性,文件在這里: test/resources/test.properties

@TestPropertySource(locations="classpath:test.properties")
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
@WebAppConfiguration
public abstract class ApplicationAbstractTest {

但是,當我運行任何測試時,它們會尋找applicaton屬性(並且看不到VM選項app.conf):

@PropertySource(value = "file:${app.conf}")
@SpringBootApplication
public class Application {

如何正確配置?

@PropertySource(value = "file:${app.conf}")添加ignoreResourceNotFound = true后,此問題已解決。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM