[在STS中运行Spring Boot应用程序时找不到Bean

问题描述 投票:0回答:2

当我尝试在STS中运行Spring Boot应用程序时得到此消息:

***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 1 of constructor in com.greglturnquist.learningspringboot2.learningspringboot2.ImageService required a bean of type 'com.greglturnquist.learningspringboot2.learningspringboot2.ImageRepository' that could not be found.


Action:

Consider defining a bean of type 'com.greglturnquist.learningspringboot2.learningspringboot2.ImageRepository' in your configuration.

我尝试添加

compile ("com.greglturnquist.learningspringboot2.learningspringboot2.ImageRepository")

build.gradle,但这没什么区别。我该如何解决?

这是我的ImageRepository类:

package com.greglturnquist.learningspringboot2.learningspringboot2;

import org.springframework.data.repository.reactive.ReactiveCrudRepository;
import reactor.core.publisher.Mono;

public interface ImageRepository extends ReactiveCrudRepository<Image, String> {

    Mono<Image> findByName(String name);

}
java spring-boot spring-tool-suite
2个回答
1
投票

更新:还要在您的配置或SpringBootApplication类上方包含@EnableJpaRepositories以将其包含在组件扫描中。


0
投票
请添加它,希望它可以解决您的问题。
© www.soinside.com 2019 - 2024. All rights reserved.