一、问题描述
使用 SpringBoot 集成 fastDFS,实现文件管理的功能,首先 在 resources 文件夹下创建 fastDFS 的配置文件 fdfs_client.conf:
connect_timeout=60
network_timeout=60
charset=UTF-8
http.tracker_http_port=8080
tracker_server=192.168.211.132:22122
然后,提供 application.yml :
spring:
servlet:
multipart:
max-file-size: 10MB
max-request-size: 10MB
application:
name: file
server:
port: 18082
eureka:
client:
service-url:
defaultZone: http://127.0.0.1:7001/eureka
instance:
prefer-ip-address: true
feign:
hystrix:
enabled: true
其中,max-file-size 是单个文件大小,max-request-size 是请求数据的大小(比如说,除了文件,还有表单)。
提供启动类:
@SpringBootApplication
@EnableEurekaClient
public class FileApplication {
public static void main(String[] args) {
SpringApplication.run(FileApplication.class,args);
}
}
运行后报错了:
二、解决方法
具体的 Action 是这样的:
Action:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
它说需要把数据库放置在 classpath 下,但是我的这个系统是不需要使用数据库的,所以需要对数据库自动配置加载的行为进行排除。
对启动类上的注释进行修改:
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
再运行,就没问题啦。