加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

spring – ApplicationContextException:由于缺少ServletWebS

发布时间:2020-12-15 01:41:58 所属栏目:大数据 来源:网络整理
导读:我使用Spring启动编写了一个Spring批处理应用程序.当我尝试在本地系统上使用命令行和类路径运行该应用程序时,它运行正常.但是,当我试图在Linux服务器上运行它时,它给了我以下异常 Unable to start web server; nested exception isorg.springframework.conte

我使用Spring启动编写了一个Spring批处理应用程序.当我尝试在本地系统上使用命令行和类路径运行该应用程序时,它运行正常.但是,当我试图在Linux服务器上运行它时,它给了我以下异常

Unable to start web server; nested exception is
org.springframework.context.ApplicationContextException: 
Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.

以下是我运行它的方式:

java -cp jarFileName.jar; lib* -Dlogging.level.org.springframework=DEBUG -Dspring.profiles.active=dev -Dspring.batch.job.names=abcBatchJob com.aa.bb.StartSpringBatch > somelogs.log
最佳答案
对于非Web应用程序,请在属性文件中禁用Web应用程序类型:

在application.properties中:

spring.main.web-application-type=none

如果您使用application.yml,则添加:

  spring:
    main:
      web-application-type: none

对于Web应用程序,在主类中扩展* SpringBootServletInitializer *.

@SpringBootApplication
public class YourAppliationName extends SpringBootServletInitializer{
    public static void main(String[] args) {
        YourAppliationName.run(YourAppliationName.class,args);
    }
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读