Consider defining a bean of type 'package' in your configuration [Spring-Boot]

https://stackoverflow.com/questions/40384056/consider-defining-a-bean-of-type-package-in-your-configuration-spring-boot

Your Applicant class is not scanned it seems. By default all packages starting with the root as the class where you have put @SpringBootApplication will be scanned.

suppose your main class "WebServiceApplication" is in "com.service.something", then all components that fall under "com.service.something" is scanned, and "com.service.applicant" will not be scanned.

You can either restructure your packages such that "WebServiceApplication" falls under a root package and all other components becomes part of that root package. Or you can include @SpringBootApplication(scanBasePackages={"com.service.something","com.service.application"}) etc such that "ALL" components are scanned and initialized in the spring container.

Update based on comment

If you have multiple modules that are being managed by maven/gradle, all spring needs is the package to scan. You tell spring to scan "com.module1" and you have another module which has its root package name as "com.module2", those components wont be scanned. You can even tell spring to scan "com" which will then scan all components in "com.module1." and "com.module2."

I am not sure if it is because I have my project broke down in modules but this is how I solved my issue of not be able to find my repositories.

@SpringBootApplication
@ComponentScan({"com.delivery.request"})
@EntityScan("com.delivery.domain")
@EnableJpaRepositories("com.delivery.repository")

Consider defining a bean of type 'package' in your configuration [Spring-Boot]

时间: 2024-12-08 11:59:15

Consider defining a bean of type 'package' in your configuration [Spring-Boot]的相关文章

spring boot注入error,Consider defining a bean of type 'xxx' in your configuration问题解决方案

经常出现这问题一定是非spring生态圈的@标签 没被spring引入,如mybatis等 因为在默认情况下只能扫描与控制器在同一个包下以及其子包下的@Component注解,以及能将指定注解的类自动注册为Bean的@[email protected]和@ Repository 那个这个时候就需要@ComponentScan或者@MapperScan了 要是xml配置注入有这问题,麻烦一遍一遍看xml文件的配置,绝对是哪里没写匹配. spring boot注入error,Consider def

启动项目,编译报错:Consider defining a bean of type 'XXX' in your configuration.

在controller层注入ConfigBean,编译器报错: 一开是以为是intellij idea 的告警级别设定的问题,就没有在意,继续启动项目,结果控制台报错:Consider defining a bean of type 'XXX' in your configuration. 错误信息显示找不到这个Bean类. 但是我明明写了啊. 后来经过一番查找,大概有了如下理解:主要问题出在@SpringBootApplication 这个注解上. 点进这个注解,可以看到,此注解功能大概由下面

Consider defining a bean of type `xxx` in your configuration问题解决问题解决

在使用SpringBoot装配mybatis时出现了异常 *************************** APPLICATION FAILED TO START *************************** Description: Field studentService in com.example.demo.action.StudentController required a bean of type 'com.example.demo.service.StudentS

springboot 工程启动报错之Consider defining a bean of type ‘XXX’ in your configuration.

一.前言: 使用springboot自动注入的方式搭建好了工程,结果启动的时候报错了!!!,错误如下图: Description: Field userEntityMapper in com.xxx.xxx.service.UserService required a bean of type 'com.xxx.xxx.dao.UserEntityMapper' that could not be found. Action: Consider defining a bean of type '

Consider defining a bean of type 'com.lvjing.dao.DeviceStatusMapper' in your configuration.

"C:\Program Files\Java\jdk1.8.0_181\bin\java.exe" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.2.4\lib\idea_rt.jar=55273:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.2.4\bin" -Dfile.enc

【spring boot】mybatis启动报错:Consider defining a bean of type 'com.newhope.interview.dao.UserMapper' in your configuration.

启动报错: 2018-02-24 22:41:00.442 WARN 2952 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error c

springboot 数据库出现 Consider defining a bean of type 'com.jc.wechat.app.dao.ClientRepository' in your configuration. 解决办法

错误日志完整: Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.2020-01-02 12:50:10.767 ERROR 8624 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : ***************************APPLICATION FA

onsider defining a bean of type 'org.springframework.jms.core.JmsTemplate' in your configuration.

启动是报没有找到这个bean的错误 第一个想就是这个JmsTemplate类加载没有, 其次是我的依赖错没有, 进过仔细检查和网上查询资料以后发现我的依赖这些注解这些是没有问题的 然后,我就很迷了,我就问了同事,他就说我的版本会不会有问题,我就看了一下我的版本,是2.1的,而2.1版本和2.0版本对于mq是有很大的区别的 onsider defining a bean of type 'org.springframework.jms.core.JmsTemplate' in your confi

Spring Boot @Autowired无法注入类 Consider defining a bean of type

SpringBoot 装备默认规则是根据Application类所在的包位置从上到下扫描, 例如 com.seed.controller com.seed.service com.seed.dao 如果 Application在com.seed.controller 这个包下, 就会无法扫描 service dao, 所以可以看到 很多博客写的spring整合mybatis 都在一个包下. 如果把Application 放在com.seed下 就可以扫描到其子包 service dao 就这个小