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的更多相关文章

  1. 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 ...

  2. ** 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 ...

  3. 解决错误: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这 ...

  4. 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 ...

  5. 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.. ...

  6. springboot之HelloWorld

    简介 为了简化开发Spring的复杂度,Spring提供了SpringBoot可以快速开发一个应用,这里就简单介绍下SpringBoot如何快速开发一个J2EE应用 HelloWorld 首先在gra ...

  7. Spring Boot踩坑之路一

    Takes an opinionated view of building production-ready Spring applications. Spring Boot favors conve ...

  8. SpringBoot的HelloWorld 应用及解释

    参考链接: Spring Data JPA - Reference Documentation Spring Data JPA--参考文档 中文版 纯洁的微笑:http://www.ityouknow ...

  9. springboot 启动报错

    有一个警告 :** WARNING ** : Your ApplicationContext is unlikely to start due to a @ComponentScan of the d ...

随机推荐

  1. CentOS7 下源码安装 python3

    CentOS 7 下源码安装 python3   在CentOS7下,默认安装的是python2.7:为满足项目要求,安装python3 的方法如下:   1. 首先安装python3.6可能使用的依 ...

  2. SoapUI SoapUI测试WebService协议接口简介

    SoapUI测试WebService协议接口简介 by:授客 QQ:1033553122 1. 创建项目,入口:File -> New SOAP Project,或者右键默认项目Project- ...

  3. 《ASP.NET MVC企业实战》(二) MVC开发前奏

    ​ 在上一篇“<ASP.NET MVC企业级实战>(一)MVC开发前奏”中记录了作者介绍的一些比较实用的VS使用方法以及C#2.0中添加的新特性.本篇继续大概了解之后版本的一些新特性.   ...

  4. Java并发编程(十四)Java内存模型

    1.共享内存和消息传递 线程之间的通信机制有两种:共享内存和消息传递:在共享内存的并发模型里,线程之间共享程序的公共状态,线程之间通过写-读内存中的公共状态来隐式进行通信.在消息传递的并发模型里,线程 ...

  5. 洗礼灵魂,修炼python(45)--巩固篇—【转载】类的__now__和__init__

    学到这里了,相信你应该对__init__非常熟悉了,就是构造器呗,当类被实例化时初始化的作用 但__init__其实不是实例化一个类的时候第一个自动调用的方法.当实例化一个类时,最先被调用的方法 其实 ...

  6. 大表分批删除脚本之MySQL版

    经常需要定期对某些表删除历史数据,通常这样的表的数据又是非常巨大,为了减轻对线上环境的影响,删除时必须分成小批量来进行. 以前分享过SQLServer的版本. 下面是MySQL版本: delimite ...

  7. psotgresql之大小写

    框中内容来自<PostgreSQL数据库对象名大小写敏感> 网址:http://bbs.chinaunix.net/forum.php?mod=viewthread&tid=812 ...

  8. git svn 流程

    $ git svn clone http://192.168.10.208/svn/DeptDoc $ git svn rebase   $ git commit -asm "svn tra ...

  9. php开发中遇到的一些问题

    php警告提示A session had already been started – ignoring session_start() 解决方案 判断 如果session_id 不存在,说明没有储存 ...

  10. JS中=>,>>>是什么意思

    最近经常看到 JS中=>,符号,于是查了一下别人的博客 =>是es6语法中的arrow function 举例:(x) => x + 6 相当于   function(x){ ret ...