控制台报错:
Field storageEngine in com.imooc.pan.server.modules.file.service.impl.IFileServiceImpl required a bean of type 'com.imooc.pan.storage.engine.core.StorageEngine' 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.imooc.pan.storage.engine.core.StorageEngine' in your configuration.
这个是StorageEngine
的接口:
package com.imooc.pan.storage.engine.core;
import com.imooc.pan.storage.engine.core.context.*;
import org.mapstruct.Mapper;
import org.springframework.stereotype.Component;
import java.io.IOException;
/**
* 文件存储引擎模块的顶级接口
* 该接口定义所有需要向外暴露给业务层面的相关文件操作的功能
* 业务方只能调用该接口的方法,而不能直接使用具体的实现方案去做业务调用
*/
public interface StorageEngine {
/**
* 存储物理文件
*
* @param context
* @throws IOException
*/
void store(StoreFileContext context) throws IOException;
/**
* 删除物理文件
*
* @param context
* @throws IOException
*/
void delete(DeleteFileContext context) throws IOException;
/**
* 存储物理文件的分片
*
* @param context
* @throws IOException
*/
void storeChunk(StoreFileChunkContext context) throws IOException;
/**
* 合并文件分片
*
* @param context
* @throws IOException
*/
void mergeFile(MergeFileContext context) throws IOException;
/**
* 读取文件内容写入到输出流中
*
* @param context
* @throws IOException
*/
void readFile(ReadFileContext context) throws IOException;
}
这个是RPanServerLauncher
启动类:
package com.imooc.pan.server;
import com.imooc.pan.core.constants.RPanConstants;
import com.imooc.pan.core.response.R;
import io.swagger.annotations.Api;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.constraints.NotBlank;
@SpringBootApplication(scanBasePackages = RPanConstants.BASE_COMPONENT_SCAN_PATH)
@ServletComponentScan(basePackages = RPanConstants.BASE_COMPONENT_SCAN_PATH)
@EnableTransactionManagement
@MapperScan(basePackages = RPanConstants.BASE_COMPONENT_SCAN_PATH + ".server.modules.**.mapper")
@EnableAsync
public class RPanServerLauncher {
public static void main(String[] args) {
SpringApplication.run(RPanServerLauncher.class);
}
}
老师我想请问一下这个报错应该怎么解决呢?谢谢!
=============================================================================
这是storage-engine
的pom文件:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.imooc.pan</groupId>
<artifactId>r-pan-framework</artifactId>
<version>1.0</version>
</parent>
<artifactId>r-pan-storage-engine</artifactId>
<packaging>pom</packaging>
<modules>
<module>storage-engine-core</module>
<module>storage-engine-local</module>
<module>storage-engine-fastdfs</module>
<module>storage-engine-oss</module>
</modules>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
这是storage-engine-fastdfs
的pom文件:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.imooc.pan</groupId>
<artifactId>r-pan-storage-engine</artifactId>
<version>1.0</version>
</parent>
<artifactId>r-pan-storage-engine-fastdfs</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.imooc.pan</groupId>
<artifactId>r-pan-storage-engine-core</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.github.tobato</groupId>
<artifactId>fastdfs-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
</dependency>
</dependencies>
</project>
这是storage-engine-core
的pom文件
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>r-pan-storage-engine</artifactId>
<groupId>com.imooc.pan</groupId>
<version>1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>r-pan-storage-engine-core</artifactId>
<properties>
<maven.compiler.source>18</maven.compiler.source>
<maven.compiler.target>18</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.imooc.pan</groupId>
<artifactId>r-pan-core</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.imooc.pan</groupId>
<artifactId>r-pan-cache-core</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</project>
server模块的pom文件中,我添加的相关存储引擎的依赖
<dependencies>
<dependency>
<groupId>com.imooc.pan</groupId>
<artifactId>r-pan-web</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.imooc.pan</groupId>
<artifactId>r-pan-swagger2</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
<dependency>
<groupId>com.imooc.pan</groupId>
<artifactId>r-pan-mybatis-plus</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.imooc.pan</groupId>
<artifactId>r-pan-schedule</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.imooc.pan</groupId>
<artifactId>r-pan-cache-redis</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.imooc.pan</groupId>-->
<!-- <artifactId>r-pan-storage-engine-local</artifactId>-->
<!-- <version>1.0</version>-->
<!-- </dependency>-->
<dependency>
<groupId>com.imooc.pan</groupId>
<artifactId>r-pan-storage-engine-fastdfs</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
=======================================================================
SpringBoot+Vue3+Element Plus 仿百度网盘实战
了解课程