在Spring Boot项目中,如果在application.yml
文件中配置自定义文件上传下载路径时遇到启动报错,可以通过以下步骤解决问题:
-
创建自定义配置文件:首先,在项目的
resources
文件夹下创建一个名为META-INF
的文件夹。然后,在这个文件夹下新建一个配置文件additional-spring-configuration-metadata.json
。在这个文件中配置需要添加的自定义配置,例如:
{ "properties": [ { "name": "spring.mvc.hiddenmethod.filter.enabled=true:mybatis-plus", "type": "java.lang.String", "description": "Description for spring.mvc.hiddenmethod.filter.enabled=true:mybatis-plus." }, { "name": "filePath.path", "type": "java.lang.String", "description": "Description for filePath.path." } ] }
-
其中,
name
是自定义配置的名称,type
是数据类型,description
是配置的描述信息。完成这些配置后,重新构建项目,application.yml
中对应的红字部分应该显示正常。 -
配置文件上传下载路径:在
application.yml
文件中配置文件的上传路径,例如: -
filePath: path: D:\img\