windows和linux设置临时上传路径
第一种windows
server:
tomcat:
basedir: /data/apps/temp
第二种 windows和linux
在application里注入bean
@bean
multipartconfigelement multipartconfigelement(){
multipartconfigfactory factory = new multipartconfigfactory();
string systemname = system.getproperty("os.name");
system.out.println("current system is : " + systemname);
if(!stringutils.isblank(systemname) && systemname.tolowercase().contains("linux")){
// linux临时路径
factory.setlocation("/data/apps/temp");
}else{
// windows临时路径
factory.setlocation("/data/apps/temp");
}
return factory.createmultipartconfig();
}
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。
发表评论