小编Aka*_*sh 的帖子

注入点有以下注释: - @org.springframework.beans.factory.annotation.Autowired(required=true)

我是 Spring Boot 的新手,在编写文件上传 API 时出现以下错误:

Error:Description:
Field fileStorageService in com.primesolutions.fileupload.controller.FileController required a bean of type 'com.primesolutions.fileupload.service.FileStorageService' that could not be found.
The injection point has the following annotations:
    - @org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean of type 'com.primesolutions.fileupload.service.FileStorageService' in your configuration.*
Run Code Online (Sandbox Code Playgroud)

控制器类:

public class FileController 
{
    private static final Logger logger = LoggerFactory.getLogger(FileController.class);

    @Autowired
    private FileStorageService fileStorageService;

    @PostMapping("/uploadFile")
    public UploadFileResponse uploadFile(@RequestParam("file") MultipartFile file) {
        String fileName = fileStorageService.storeFile(file);

        String fileDownloadUri = ServletUriComponentsBuilder.fromCurrentContextPath()
                .path("/downloadFile/")
                .path(fileName)
                .toUriString();

        return new UploadFileResponse(fileName, fileDownloadUri, …
Run Code Online (Sandbox Code Playgroud)

java spring-boot

9
推荐指数
2
解决办法
6万
查看次数

标签 统计

java ×1

spring-boot ×1