写完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
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
2018-05-21
@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; }}
举报