一枚加班的程序猿
2018-05-21 18:47
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
工程路径建议不要中文
@PropertySource(value="classpath:resource.properties")
工程结构如图,注释
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; }}
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
是哪个文件写错了
resource.properties这个文件存在吗?
SpringBoot开发常用技术整合
102171 学习 · 508 问题
相似问题