spring - Sprin Boot: Repository bean not found
问题描述
I'm building applications that could use the same entities and repository classes. So I create a lib with these objects and installed it in Maven and included a dependency in pom.xml
in the new project. However, when I call the page the error below appears.
The lib contains the configuration DB class and in the all declaration of the service in the new project's controller I use the annotation @Autowired
. Tomcat does not show any problem on start.
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-08-02 09:54:53.546 ERROR 20368 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Field repository in br.com.service.PersonService required a bean of type 'br.com.repository.PersonRepository' 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 'br.com.repository.PersonRepository' in your configuration.
EDIT:
Configuration:
@SpringBootApplication
@EntityScan(basePackages = { "br.com.*" })
@EnableCassandraRepositories(basePackages = { "br.com.*" })
@ComponentScan(basePackages = {"br.com.*"})
public class App extends SpringBootServletInitializer
{
public static void main( String[] args )
{
SpringApplication.run(App.class, args);
}
}
POM.XML with my lib with the commons objects:
<dependency>
<groupId>br.com</groupId>
<artifactId>objetos.base</artifactId>
<version>1.2.2</version>
</dependency>
Lib Repository:
@Repository
public interface PersonRepository extends CassandraRepository<Person, UUID>{
Lib Service:
@Service
public class PersonService {
@Autowired
private PersonRepository repository;
Does anyone have any idea what is happening?
解决方案
推荐阅读
- python - 在 Python 中将 CSV 文件转换为 2D 表
- c# - 访问存储在智能卡上的证书
- python - 编写代码延迟游戏时游戏死机?
- apache-nifi - 如何使 ScriptEventHookProvider 工作?
- java - 我如何在本地 maven 存储库中搜索包
- javascript - 链接请求会加速 TTFB 吗?
- r - 在 pivot_longer 中通过 match 包含列同时手动排除其他列的正确方法是什么?
- python - 如何在依赖于 repo 中其他文件的 github repo 中测试我的脚本
- javascript - Three.js raycaster 导致动画不显示
- ruby-on-rails - NameError(未初始化的常量 BCrypt)