当我尝试在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);
}
更新:还要在您的配置或SpringBootApplication类上方包含@EnableJpaRepositories以将其包含在组件扫描中。