springboot 闪退。falling back to default profiles: default StandardService - Stopping service [Tomcat]

大家好,我是烤鸭:

      今天分享一个springboot 闪退的问题。确切得说是没有起来。

环境:

      springboot 版本 2.1.0.RELEASE

异常:

2019-05-25 19:39:00.822 ==> [main] ==> INFO  com.cgmanage.migrate.MigrateApplication - Starting MigrateApplication v1.0.0-SNAPSHOT on localhost with PID 27493 (/opt/web_app/data_migrate/test-1.0.0.jar started by root in /opt/web_app/data_migrate)
2019-05-25 19:39:00.827 ==> [main] ==> DEBUG com.cgmanage.migrate.MigrateApplication - Running with Spring Boot v2.1.0.RELEASE, Spring v5.1.2.RELEASE
2019-05-25 19:39:00.830 ==> [main] ==> INFO  com.cgmanage.migrate.MigrateApplication - No active profile set, falling back to default profiles: default
2019-05-25 19:39:04.153 ==> [main] ==> INFO  org.apache.coyote.http11.Http11NioProtocol - Initializing ProtocolHandler ["http-nio-8085"]
2019-05-25 19:39:04.172 ==> [main] ==> INFO  org.apache.catalina.core.StandardService - Starting service [Tomcat]
2019-05-25 19:39:04.172 ==> [main] ==> INFO  org.apache.catalina.core.StandardEngine - Starting Servlet Engine: Apache Tomcat/9.0.12
2019-05-25 19:39:04.195 ==> [main] ==> INFO  org.apache.catalina.core.AprLifecycleListener - The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]
2019-05-25 19:39:04.346 ==> [main] ==> INFO  o.a.c.core.ContainerBase.[Tomcat].[localhost].[/] - Initializing Spring embedded WebApplicationContext
2019-05-25 19:39:04.620 ==> [main] ==> INFO  org.apache.catalina.core.StandardService - Stopping service [Tomcat]

主要在于这两行:

    No active profile set, falling back to default profiles: default
    org.apache.catalina.core.StandardService - Stopping service [Tomcat]

解决方案:

      网上说的是添加 springboot-web 的依赖,但是没用。

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

降低springboot 版本至 2.0.5.RELEASE ,还是不行。
同样的项目,测试环境可以跑起来,生产环境闪退,唯一的区别在于启动时指定的配置文件不同。
仔细对比配置文件,发现确实有个地方不一样。

测试环境的配置文件:

server:
  port: 8085
spring:
  application:
    name: test-migrate
  datasource:
    write:
      jdbc-url: jdbc:mysql://localhost:3306/test?useSSL=false&allowMultiQueries=true&useUnicode=true&characterEncoding=utf8
      username: root
      password: root
      driver-class-name: com.mysql.jdbc.Driver
      type: com.zaxxer.hikari.HikariDataSource
      idleTimeout: 180000
      connectionTimeout: 180000
      validationTimeout: 6000
      maxPoolSize: 200
      minIdle: 100

生产的配置文件比测试少了一行。
idleTimeout: 180000

没错。就差这一行。
如果你也是跟我有一样的问题,
日志打印也没报错的话。
建议
检查一下配置文件,仔细对比一下。。。surprise

发布了115 篇原创文章 · 获赞 58 · 访问量 23万+

猜你喜欢

转载自blog.csdn.net/Angry_Mills/article/details/90610144