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/details/65942092
错误提示:
** WARNING ** : Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package
// 警告:你的应用上下文可能没有启动,因为你将注解添加到了默认的package上面了
原因解析:
SpringBoot在写启动类的时候如果不使用@ComponentScan指明对象扫描范围,默认指扫描当前启动类所在的包里的对象,如果当前启动类没有包,则在启动时会报错:Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package错误。
因为启动类不能直接放在main/java文件夹下,必须要建一个包把它放进去或者使用@ComponentScan指明要扫描的包。
解决方法:
方法一:在main/java下建个包,将Application文件放进去;
方法二:在Application类上面加@ComponentScan注解,指定要扫描的包,如下:
@SpringBootApplication
@EnableEurekaClient
@ComponentScan(basePackageClasses = TestClass.class )
public class ClientDemoApplication {
public static void main(String[] args) {
SpringApplication.run(ClientDemoApplication.class, args);
}
}
@ComponentScan(basePackageClasses=要扫描类.class所在位置的包)-意思是要扫描哪个类所在的包
Java问题解决:springboot启动出现-Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package的更多相关文章
- 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 @Comp ...
- ** 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 ...
- springboot 启动报错
有一个警告 :** WARNING ** : Your ApplicationContext is unlikely to start due to a @ComponentScan of the d ...
- 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 启动的java进程默默终止
首先说明这是一个灵异事件......... 场景1 :把之前用map实现的缓存用Redis重构,高高兴兴上线更新,10 分钟后,老板告诉我,项目停了,what ??? 像我这么帅气,英俊,聪明的人,更 ...
- (四)SpringBoot启动过程的分析-预处理ApplicationContext
-- 以下内容均基于2.1.8.RELEASE版本 紧接着上一篇(三)SpringBoot启动过程的分析-创建应用程序上下文,本文将分析上下文创建完毕之后的下一步操作:预处理上下文容器. 预处理上下文 ...
- (五)SpringBoot启动过程的分析-刷新ApplicationContext
-- 以下内容均基于2.1.8.RELEASE版本 紧接着上一篇[(四)SpringBoot启动过程的分析-预处理ApplicationContext] (https://www.cnblogs.co ...
随机推荐
- git reset与git revert的区别
http://alpha-blog.wanglianghome.org/2010/07/30/git-partial-rollback/ reset(版本撤回) 格式 git reset [-q] [ ...
- webpack(6)-模块热替代&tree shaking
模块热替换(hot module replacement 或 HMR) 模块热替换(hot module replacement 或 HMR)是 webpack 提供的最有用的功能之一.它允许在运行时 ...
- mysql添加用户,授权,刷新权限
创建用户 CREATE USER 'test'@'localhost' IDENTIFIED BY '123456'; 赋权 GRANT ALL PRIVILEGES ON *.* TO 'test' ...
- jpa报错:Table 'dev-test.hibernate_sequence' doesn't exist
Hibernate 能够出色地自动生成主键.Hibernate/EBJ 3 注释也可以为主键的自动生成提供丰富的支持,允许实现各种策略.其生成规则由@GeneratedValue设定的.这里的@id和 ...
- python headers missing
系统环境 win7 64 bit,cygwin,Gvim8.1 问题 Gvim通过插件管理器Vundle下载好了YouCompleteMe插件的全部文件. 利用cygwin 进入在YouComplet ...
- java 访问数据库
Class.forName(“com.microsoft.sqlserver.jdbc.SQLServerDriver”);//依据不同数据库,加载不同驱动 String url = “jdbc:sq ...
- platform怎么实现数据数据和驱动分离
一些重要的结构体: struct platform_device { const char * name; int id; struct device dev; u32 num_resources; ...
- laravel5.7 migrate 时报错 Specified key was too long error 解决方案
今天在数据迁移时突然报了 Specified key was too long error 的错,解决掉之后就把这个问题记录下来. 报错原因 Laravel 5.4 + 默认使用 utf8mb4 字 ...
- 信步漫谈之Jenkins—集成自动化部署 SVN 项目
一.环境准备 1)Jenkins 部署 WAR 包:jenkins.war(2.164.2 版本,WAR 包官方下载路径:https://jenkins.io/download/)2)Tomcat 服 ...
- WindowsService调用API
本文着重于WindowsServic如何调用API以及出现部分问题的解决方案 本文Windows Service 创建摘自JasperXu的博客 链接:http://www.cnblogs.com ...