错误信息:
***************************
APPLICATION FAILED TO START
***************************
Description:
Binding to target [Bindable@7125333 type = , value = 'provided', annotations = array<Annotation>[@(prefix=application, value=application, ignoreUnknownFields=false, ignoreInvalidFields=false)]] failed:
Property: -path
Value: D:/demo
Origin: "-path" from property source "applicationConfig: [classpath:/config/]"
Reason: The elements [-path] were left unbound.
Action:
Update your application's configuration
解决办法:
首先看一下启动的配置文件是不是当前设置的值的文件,不要在dev里配置了upload-path启动的是prod的配置文件
然后在项目的config文件夹下新建java文件(如果有就不需要创建了)
import ;
@ConfigurationProperties(prefix = "application", ignoreUnknownFields = false)
public class ApplicationProperties {
private String uploadPath;
public String getUploadPath() {
return uploadPath;
}
public void setUploadPath(String uploadPath) {
= uploadPath;
}
}
这样,在其他类里就可以引用配置文件中配置的值了
public class serviceTest {
@Value("${-path}")
private String uploadPath;
}