第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

springboot juint 測(cè)試 Could not open ServletContext resource [/application.yml]

junit測(cè)試時(shí)一直提示Could not open ServletContext resource [/application.yml]

目錄結(jié)構(gòu)

https://img1.sycdn.imooc.com//5b38a268000147b505890556.jpg

service層測(cè)試代碼


@RunWith(SpringRunner.class)
@SpringBootTest(classes?=?GirlApplication.class)//啟動(dòng)整個(gè)springboot功能
public?class?GirlServcieTest?{
????@Autowired
????private?GirlService??girlService;
????@Test
????public?void?findById(){
????????Girl?byId?=?girlService.findById(1);
????????Assert.assertEquals(new?Integer(9),byId.getAge());
????}
}

問題:

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.springboot.GirlApplication]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/application.yml]

at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:183) ~[spring-context-4.3.18.RELEASE.jar:4.3.18.RELEASE]

at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:308) ~[spring-context-4.3.18.RELEASE.jar:4.3.18.RELEASE]

at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:228) ~[spring-context-4.3.18.RELEASE.jar:4.3.18.RELEASE]

at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:272) ~[spring-context-4.3.18.RELEASE.jar:4.3.18.RELEASE]

at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:92) ~[spring-context-4.3.18.RELEASE.jar:4.3.18.RELEASE]

at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:687) ~[spring-context-4.3.18.RELEASE.jar:4.3.18.RELEASE]

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:525) ~[spring-context-4.3.18.RELEASE.jar:4.3.18.RELEASE]

at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) ~[spring-boot-1.5.14.RELEASE.jar:1.5.14.RELEASE]


正在回答

4 回答

這是什么原因

0 回復(fù) 有任何疑惑可以回復(fù)我~

在@SpringBootTest中增加加webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT

@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(webEnvironment?=?SpringBootTest.WebEnvironment.RANDOM_PORT)
public?class?PersonTest?{
}

剛剛在github上找到一個(gè)方法,解決了

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

慕九州1402278

確實(shí)可以用,什么原因哈
2019-08-21 回復(fù) 有任何疑惑可以回復(fù)我~

我也遇到同樣的問題,請(qǐng)問樓主解決了么

0 回復(fù) 有任何疑惑可以回復(fù)我~

檢查一下你的Springboot版本

@SpringBootTest(classes={Application.class})// 指定啟動(dòng)類

@SpringApplicationConfiguration(classes = Application.class)// 1.4.0 前版本

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消
Spring Boot進(jìn)階之Web進(jìn)階
  • 參與學(xué)習(xí)       104159    人
  • 解答問題       425    個(gè)

《2小時(shí)學(xué)習(xí)Spring Boot》之進(jìn)階教程,針對(duì)Web方面的相關(guān)技巧

進(jìn)入課程

springboot juint 測(cè)試 Could not open ServletContext resource [/application.yml]

我要回答 關(guān)注問題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)