关于idea,springboot启动最新版ibase4j报Unable to start ServletWebServerApplicationContext due to missing Serv

使用ibase4j开发了一段时间,两个字“好用”。不过最近有新入行的朋友需要分享一下ibase4j。
于是就去下载了最新版本的ibase4j,给新朋友演示。后面就出问题了,项目启动就报:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-09-03 17:07:53.540 [main] ERROR [SpringApplication:842] - Application run failed
org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:155) ~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
    at org.ibase4j.SysServiceApplication.main(SysServiceApplication.java:13) [classes/:?]
Caused by: org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getWebServerFactory(ServletWebServerApplicationContext.java:204) ~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:178) ~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:152) ~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]


这个错误,后面使用百度csdn博文+翻看源码+ibase4j+Q群询问后发现是如下代码导致:

在ibase4j的主maven依赖配置文件pom.xm里声明有spring-boot-starter-tomcat配置

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
  
  

scope:provided表示参与测试运行,但不参与编译打包,打包由运行环境提供。
现在需要参与编译打包,于是把scope的provided改成了complie,果然启动成功。
但是考虑到,作者既然发布这样配置,那么表示对作者感知而言应该是可以运行的。突然想到作者可能是用eclipse开发,会不会是运行环境的差异。
于是在搜索引擎搜索相关资料,并查看了idea的启动配置,果然发现了问题。
这里写图片描述
选择Edit Configuration…
这里写图片描述
选择SpringBoot的配置,勾上Include dependencies with “Provided” scope
点击OK
再次启动项目,运行成功!
这里写图片描述
总结这个应该是开发环境差异导致。明显idea提供这个勾选项,是为了方便用户打包,但是在运行时,需要勾上。
参考:
1、iBase4J一群 聊天记录
2、maven中scope标签详解

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值