请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

启动后端项目报错

控制台报错:

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>

=======================================================================
图片描述

正在回答 回答被采纳积分+3

1回答

RubinChu 2023-06-25 00:23:43

把存储引擎的实现依赖引一下,之后刷新maven

0 回复 有任何疑惑可以回复我~
  • 提问者 weixin_慕瓜4554205 #1
    老师,我把依赖引入了也刷新了maven,还是提示相同的错误。
    回复 有任何疑惑可以回复我~ 2023-06-26 15:39:26
  • RubinChu 回复 提问者 weixin_慕瓜4554205 #2
    在server模块,引入具体的存储引擎依赖就行了
    回复 有任何疑惑可以回复我~ 2023-06-26 15:51:00
  • 提问者 weixin_慕瓜4554205 回复 RubinChu #3
    老师我的server里面的依赖我引入的就是fastdfs的依赖。(具体的依赖在原始提问里面,我更新了)
    回复 有任何疑惑可以回复我~ 2023-06-26 23:27:16
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信