现象

这几天一直被一个问题困扰,每次springboot的tomcat启动之后, 然后过了一段时间看, 进程就突然自己关闭掉了。 然后日志是:

ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@6d5380c2: startup date [Sun Sep 24 17:51:04 CST 2017]; root of context hierarchy
o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'

解法

网上也有说这个问题, 但是大多数说的是, 这个是一个非 web应用, 需要添加这个依赖,链接

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

要么就是添加tomcat的依赖。

但是搞了很多次发现原来是怎么样,就是怎么样, 直到看到这篇文章 , 才发现,原来是启动方式的问题, 需要加 nohup, 然后加了 nohup, 果然就好了。这也纠正了我的一个误区, 我一直以为 & 和 nohup是一样的。

nohup 和 &

可以参考这篇文章

简单来说就是:

  • 用nohup运行命令可以使命令永久的执行下去,和用户终端没有关系,例如我们断开SSH连接都不会影响他的运行,注意了nohup没有后台运行的意思;&才是后台运行
  • &是指在后台运行,但当用户推出(挂起)的时候,命令自动也跟着退出

springboot启动后总是自己shutdown的更多相关文章

  1. springboot启动后自动退出

    有时新建的springboot启动后自动退出运行,如图所示: 此种情况大都数是因为pom文件加入了tomcat的依赖,与springboot内嵌的tomcat冲突导致,所以只需将pom文件中的tomc ...

  2. SpringBoot启动后自动打开浏览器访问项目

    之前我们用SSM或者SSH进行JAVA WEB开发的时候,IDEA 需要配置Tomcat然后把项目放到tomcat运行,tomcat启动的时候会自动打开浏览器去访问项目,但是SpringBoot是内嵌 ...

  3. springBoot启动后 http://localhost:8080 地址无法访问

    http://localhpost:8080/hello 代码结构: 代码内容: @RestController public class HelloWordRestImpl implements H ...

  4. 1. SpringBoot启动后,报异常:This application has no explicit mapping for /error, so you are seeing this as a fallback.

    出现这个异常说明了跳转页面的url无对应的值. 原因1: Application启动类的位置不对.要将Application类放在最外侧,即包含所有子包 原因:spring-boot会自动加载启动类所 ...

  5. springboot启动后执行一段代码的方式

    文章转载自: https://www.cnblogs.com/zuidongfeng/p/9926471.html https://blog.csdn.net/zknxx/article/detail ...

  6. spring-boot启动后在浏览器打开指定页面

    来自:https://stackoverflow.com/questions/27378292/launch-browser-automatically-after-spring-boot-webap ...

  7. Springboot项目启动后自动创建多表关联的数据库与表的方案

    文/朱季谦 在一些项目开发当中,存在这样一种需求,即开发完成的项目,在第一次部署启动时,需能自行构建系统需要的数据库及其对应的数据库表. 若要解决这类需求,其实现在已有不少开源框架都能实现自动生成数据 ...

  8. Springboot 项目启动后执行某些自定义代码

    Springboot 项目启动后执行某些自定义代码 Springboot给我们提供了两种"开机启动"某些方法的方式:ApplicationRunner和CommandLineRun ...

  9. springboot 学习之路 9 (项目启动后就执行特定方法)

    目录:[持续更新.....] spring 部分常用注解 spring boot 学习之路1(简单入门) spring boot 学习之路2(注解介绍) spring boot 学习之路3( 集成my ...

随机推荐

  1. Web API的参数、多版本和Filter

    一.关于API的参数a) Web API在WebApiConfig.cs中配置了路由模板,默认为"api/{controller}/{id}",这与MVC路由模板的区别在于没有{a ...

  2. Jenkins报错'Gradle build daemon disappeared unexpectedly'的问题解决

    在将项目集成到 Jenkins 后,经常会出现不稳定的构建,Jenkins 控制台输出的错误信息为:Gradle build daemon disappeared unexpectedly (it m ...

  3. git批量修改已经提交的commit的姓名和邮箱

    首先,我们创建change.sh脚本,并根据个人信息复制以下脚本. #!/bin/sh git filter-branch --env-filter ' OLD_EMAIL="填写原来的邮箱 ...

  4. PHP类多继承的替代方案Traits

    概述 traits是PHP5.4新进入的特性,其目的就是解决PHP的类不能多继承的问题.Traits不是类!不能被实例化.可以理解为一组能被不同的类都能调用到的方法集合.只需要在类中使用关键词use引 ...

  5. [20170916]sqlplus set array最小2补充.txt

    [20170916]sqlplus set array最小2补充.txt --//以前写的贴子,链接http://blog.itpub.net/267265/viewspace-1453652/--/ ...

  6. C# MD5 加密

    public static string MD5Encrypt(string clearText) { string result = string.Empty; byte[] byteArray = ...

  7. [MapReduce_3] MapReduce 程序运行流程解析

    0. 说明 Word Count 程序运行流程解析 &&  MapReduce 程序运行流程解析 1. Word Count 程序运行流程解析 2. MapReduce 程序运行流程图

  8. SQL Server2008 18456错误

    1.以windows验证模式进入数据库管理器.   第二步:右击sa,选择属性:   在常规选项卡中,重新填写密码和确认密码(改成个好记的).把强制实施密码策略去掉.   第三步:点击状态选项卡:勾选 ...

  9. django知识点回顾(上)

    Django---知识点: 1. 配置文件: media: avatar = models.FileField(upload_to='avatar')#数据库里的model MEDIA_ROOT=os ...

  10. Linter pylint is not installed

    问题 Linter 'pylint' is not installed. Please install it or select another linter". Error: Module ...