Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package
1、在搭建SpringBoot框架时碰到的问题。
** WARNING ** : Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package.
警告:你的应用上下文可能没有启动,因为你将注解添加到了默认的package上面了。下面的堆栈信息中也有一句话包括了这个意思。
......This can also happen if you are @ComponentScanning a springframework package (e.g. if you put a @ComponentScan in the default package by mistake)。
(启动的时候还有其他的错误,这里只摘录跟这个相关的错误。)
2、我的项目结构是这样的(我将Application的文件建在了java文件夹下面)
3、原因解析
我并没有使用@ComponentScanning注解,这里为什么会蹦出个这样的注解呢?
SpringBoot在编写启动类(Main方法所在的类)的时候如果不使用@ComponentScan指明对象扫描范围,默认指扫描当前启动类所在的包里的对象。
(注意:我在编写Main方法的时候并没有加@ComponentScan注解,因而,他会扫描Application所在的包里的对象)
如果当前启动类没有包,则在启动时会报错:Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package错误。
(注意:写在java文件夹下的Application类,是不从属于任何一个包的,因而启动类没有包)
4、解决办法
方法一、将Application建在其他的包下面
方法二、在Application类上面加@ComponentScan注解,指定要扫描的包
参考文档
http://blog.csdn.net/u012834750/article/details/65942092
Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package的更多相关文章
- Java问题解决:springboot启动出现-Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package
参考资料: http://www.mamicode.com/info-detail-2101273.html https://blog.csdn.net/u012834750/article/deta ...
- ** WARNING ** : Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package.
https://blog.csdn.net/qq_15071263/article/details/78459087 1. 警告解读 ** WARNING ** : Your ApplicationC ...
- 解决错误:Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package.
原因是代码直接放在默认包里边,比如src\main\java目录下 应该在src\main\java下建立子目录,比如src\main\java\com\test 这样的话,代码就在com.test这 ...
- Your ApplicationContext is unlikely to start due to a @ComponentScan of the default
问题:** WARNING ** : Your ApplicationContext is unlikely to start due to a @ComponentScan of the defau ...
- Your ApplicationContext is unlikely tostart due to a @ComponentScan of the defau
一.错误提示: Your ApplicationContext is unlikely tostart due to a @ComponentScan of the default package.. ...
- springboot之HelloWorld
简介 为了简化开发Spring的复杂度,Spring提供了SpringBoot可以快速开发一个应用,这里就简单介绍下SpringBoot如何快速开发一个J2EE应用 HelloWorld 首先在gra ...
- Spring Boot踩坑之路一
Takes an opinionated view of building production-ready Spring applications. Spring Boot favors conve ...
- SpringBoot的HelloWorld 应用及解释
参考链接: Spring Data JPA - Reference Documentation Spring Data JPA--参考文档 中文版 纯洁的微笑:http://www.ityouknow ...
- springboot 启动报错
有一个警告 :** WARNING ** : Your ApplicationContext is unlikely to start due to a @ComponentScan of the d ...
随机推荐
- Log4J Appender - 将Log4J的日志内容发送到agent的source
项目中使用log4j打印的内容同时传输到flume 1.flume端 flume的agent配置内容如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 a1.sour ...
- (网页)angularjs中的验证input输入框只能输入数字和小数点
百度的资料:自己记录看下 把js的验证方法改成angular可使用的方法 AngularJS文件的写法: $scope.clearNoNum = function(obj,attr){ //先把非数字 ...
- (后端)SQL Server日期时间函数
转自博客园: 1.获取当前日期GetDate getdate()函数以datetime数据类型的格式返回当前SQLServer服务器所在计算机的日期和时间.其语法格式为getdate().返回值舍入到 ...
- DB2表被锁,如何解锁
原因与解决方案 1.原因:修改表结构表结构发生变化后再对表进行任何操作都不被允许,SQLState为57016(因为表不活动,所以不能对其进行访问),由于修改了表字段权限,导致表处于不可用状态 2.解 ...
- 用LinQ扩展方法,泛型扩展方法,实现自定义验证字符是否空、对象是否为null,及泛型约束使用,Action的使用
一.Linq扩展方法 1.扩展方法必须是静态方法.扩展方法所在的类必须是静态类 2.扩展方法里面的参数必须制定this关键字,紧跟需要扩展的类型,如下: 二.泛型约束 1.使用泛型的原因,是在不知道需 ...
- Asp.net Mvc身份验证
1.安装组件 Microsoft.AspNet.Identity.Core,身份认证核心组件 安装Microsoft.AspNet.Identity.EntityFramework,EF实现身份认证 ...
- 读取HTML文件进行格式化解析
#读取HTML文件进行格式化解析 $html = New-Object -ComObject "HTMLFile"; $source = Get-Content -Path &qu ...
- WPFのGrid布局的深度理解
以下以row定义说明问题,列类似: <Grid> <Grid.RowDefinitions> <RowDefinition /> ...
- 开启 J2EE(一)—‘全明星队伍’
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/akkzhjj/article/details/27973427 J2EE-一套规范 J2EE(Jav ...
- 全排列(dfs)
无重复元素的全排列 输入n(<=11),按从小到大输出数字1 到n 个的全部排列.样例:输入:3输出:1:1 2 32:1 3 23:2 1 34:2 3 15:3 1 26:3 2 1 全排列 ...