Intellij Idea下运行Spring Boot关于provided依赖不加入classpath的bug与解决方案
来源:互联网 发布:百度4字优化 编辑:程序博客网 时间:2024/06/16 19:29
idea 启动项目的时候报错(Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean),主要是以下的依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<version>${springboot-version}</version>
<scope>provided</scope>
</dependency>
由于打包是不需要tomcat的,所以这里把tomcat的依赖改为provided,那么问题来了,由于idea存在一个bug,就是provided的pom不会加入classpath中,所以运行的时候就找不到tomcat相关的包,
在 Intellij Idea 16 中使用maven时,所有 scope 为 provided
的依赖都是不会被加入到 classpath 中的,目前该bug尚未被修复(bug report)。如果你的web应用是部署到容器中的,那么这个bug不会影响使用,因为web应用中provided
的依赖在容器运行时会被提供。如果你做spring Boot开发,有带provided
的依赖时,直接在IDE中运行项目会导致ClassNotFound
异常。解决方案有二:
- 使用
spring-boot:run
这个 maven goal 运行程序。但这样会失去 Idea 的 debug功能,不推荐。 - 点击IDE右侧的
Maven Projects
, 找到spring-boot:run
,右键选择 debug 运行,如图:
这种方式 ide 的 debug 功能就能正常使用了。
阅读全文
0 0
- Intellij Idea下运行Spring Boot关于provided依赖不加入classpath的bug与解决方案
- Intellij Idea下运行Spring Boot关于provided依赖不加入classpath的bug与解决方案
- Intellij Idea下运行Spring Boot关于provided依赖不加入classpath的bug与解决方案
- IntelliJ IDEA下使用默认Spring MVC框架运行失败的解决方案
- IntelliJ IDEA + Spring Boot + Mybatis的整合
- intellij idea创建运行spring boot项目时报错
- IntelliJ IDEA Spring Boot(8)使用JSP,打包jar文件运行带有jsp的项目
- Spring下classpath与classpath*的区别
- IntelliJ idea 找不到classpath 为test resource下的
- 在IntelliJ IDEA下搭建基于Maven的spring boot框架
- eclipse与intellij idea中的classpath分析
- eclipse与intellij idea中的classpath分析
- IntelliJ IDEA搭建Spring Boot的小Demo
- IntelliJ IDEA Spring Boot(3) 数据库JDBC的使用
- IntelliJ IDEA 创建spring boot 的Hello World 项目
- Intellij Idea 在spring-mybatis下因不编译resources配置文件,无法启动tomcat的问题
- IntelliJ IDEA打开Maven项目,所有依赖红名,不可用,简单解决方案
- 关于Spring加载classpath与classpath*的过程剖析
- 带你玩转Eclipse项目转成AndroidStudio项目
- 带URL超链接的饼图-使用highcharts
- 阿里云半年免费服务器申请
- 在windows10下excel导出Retrieving the COM class factory for component with CLSID .. failed due to the fol
- Modbus协议名词解析
- Intellij Idea下运行Spring Boot关于provided依赖不加入classpath的bug与解决方案
- XML文档帮助类,静态方法,实现对XML文档的创建,及节点和属性的增、删、改、查
- Error:UNEXPECTED TOP-LEVEL ERROR:
- MacBook Pro 外接显示器设置竖屏
- 2 Racket 要点
- Windows下SVN服务器搭建与使用图文教程(二)
- java-IO
- 关于Mysql in linux
- Retrofit — Getting Started and Creating an Android Client