亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

寫完saveUser 方法后啟動工程報錯

Failed to parse configuration class [com.springboot.SpringbooteApplication]; nested exception is java.io.FileNotFoundException: class path resource [resource.properties] cannot be opened because it does not exist

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


正在回答

4 回答

工程路徑建議不要中文

0 回復 有任何疑惑可以回復我~
@PropertySource(value="classpath:resource.properties")

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

工程結構如圖,注釋

package?com.springboot.pojo;import?org.springframework.boot.context.properties.ConfigurationProperties;import?org.springframework.context.annotation.Configuration;import?org.springframework.context.annotation.PropertySource;//讀配置文件中內容一定要先maven編譯一遍!!!!!!//.properties配置文件映射類//@Configuration?表示引用資源文件@Configuration//配置文件前綴@ConfigurationProperties(prefix="com.springboot.opensource")//resource.properties?文件路徑@PropertySource(value="classpath:resource.properties")public?class?Resource?{	private?String?name;	private?String?website;	private?String?language;		public?String?getName()?{		return?name;	}	public?void?setName(String?name)?{		this.name?=?name;	}	public?String?getWebsite()?{		return?website;	}	public?void?setWebsite(String?website)?{		this.website?=?website;	}	public?String?getLanguage()?{		return?language;	}	public?void?setLanguage(String?language)?{		this.language?=?language;	}}


0 回復 有任何疑惑可以回復我~

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

Failed to parse configuration class [com.springboot.SpringbooteApplication]; nested exception is java.io.FileNotFoundException: class path resource [resource.properties] cannot be opened because it does not exist


是哪個文件寫錯了

0 回復 有任何疑惑可以回復我~
#1

一枚加班的程序猿 提問者

要改成什么樣子
2018-06-05 回復 有任何疑惑可以回復我~

resource.properties這個文件存在嗎?

0 回復 有任何疑惑可以回復我~
#1

一枚加班的程序猿 提問者

存在的,需要刪掉嗎?
2018-06-05 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

寫完saveUser 方法后啟動工程報錯

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號