Error creating bean with name 'imageService' defined in file

36 views Asked by At

this is my problems problem childProblem and this's project structure project structure I have tried many methods, but it doesn’t seem to be the main problem. I don’t know if it’s because I missed something or if it was a configuration error that caused a conflict, or if I wrote mybatis plus wrong.

I used mybatis plus, below is some main code

//Controller.java
@RestController
public class ImagesController {
    @Autowired
    ImageService imageService;

    @GetMapping("/images")
    public Result list(@RequestParam(defaultValue = "1") Integer currentPage) {
        Page page = new Page(currentPage, 5);
        IPage pageData = imageService.page(page, new QueryWrapper<Image>().orderByDesc("created"));

        return Result.succ(pageData);
    }

    @PostMapping("/images")
    public Result upload(@Validated @RequestBody ImageVO imageVO) {
        Image image = imageVO.createImage();
        int id = imageService.update(image);
        return Result.succ(id);
    }

}

//ImageService Interface
public interface ImageService extends IService<Image> {
    int update(Image image);

}
//ImageServiceImpl.java
@Service()
public class ImageServiceImpl extends ServiceImpl<ImageMapper, Image> implements ImageService {
    @Override
    public int update(Image image) {
        return 0;
    }
}
//mapper
@Mapper
public interface ImageMapper extends BaseMapper<Image> {

}
//Startup class
@SpringBootApplication
@MapperScan("com.example.imageshare.mapper")
public class ImageshareApplication {

    public static void main(String[] args) {
        SpringApplication.run(ImageshareApplication.class, args);
    }

}
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.1.5</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>imageshare</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>imageshare</name>
    <description>imageshare</description>
    <properties>
        <java.version>17</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>mysql-connector-j</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.4.2</version>
        </dependency>

        <!-- hutool工具类-->
        <dependency>
            <groupId>cn.hutool</groupId>
            <artifactId>hutool-all</artifactId>
            <version>5.3.3</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

what exactly caused this problem?

i don't know what to do

0

There are 0 answers