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

本文分享了Spring Boot闪退问题,环境为Spring Boot 2.1.0.RELEASE版本,异常信息包含‘No active profile set’等。尝试添加依赖、降低版本均未解决。对比测试和生产环境配置文件,发现生产配置文件少了‘idleTimeout: 180000’一行,建议检查配置文件。

大家好,我是烤鸭:

      今天分享一个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

11-05 21:27:09:016 INFO 42876 --- [ main] cn.itcast.user.UserApplication : No active profile set, falling back to default profiles: default 11-05 21:27:09:596 INFO 42876 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=627a2a21-b8af-319a-b72a-2bad65cda331 11-05 21:27:09:936 INFO 42876 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8081 (http) 11-05 21:27:09:952 INFO 42876 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 11-05 21:27:09:952 INFO 42876 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.43] 11-05 21:27:10:080 INFO 42876 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 11-05 21:27:10:080 INFO 42876 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1041 ms 11-05 21:27:10:366 WARN 42876 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources. 11-05 21:27:10:367 INFO 42876 --- [ main] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath. 11-05 21:27:10:374 WARN 42876 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources. 11-05 21:27:10:374 INFO 42876 --- [ main] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath. 11-05 21:27:10:536 INFO 42876 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService &#39;applicationTaskExecutor&#39; 11-05 21:27:11:158 INFO 42876 --- [ main] o.s.s.c.ThreadPoolTaskScheduler : Initializing ExecutorService &#39;Nacos-Watch-Task-Scheduler&#39; 11-05 21:27:18:406 WARN 42876 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean &#39;webServerStartStop&#39;; nested exception is org.springframework.boot.web.server.PortInUseException: Port 8081 is already in use 11-05 21:27:24:458 INFO 42876 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService &#39;applicationTaskExecutor&#39; 11-05 21:27:24:461 INFO 42876 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat] 11-05 21:27:24:473 INFO 42876 --- [ main] ConditionEvaluationReportLoggingListener : Error starting ApplicationContext. To display the conditions report re-run your application with &#39;debug&#39; enabled. 11-05 21:27:24:478 ERROR 42876 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPLICATION FAILED TO START *************************** Description: Web server failed to start. Port 8081 was already in use. Action: Identify and stop the process that&#39;s listening on port 8081 or configure this application to listen on another port.
11-06
2025-12-08 09:12:28.332 [main] INFO io.tubo.cv3.Cv3Application - Starting Cv3Application on CHINAMI-EH9OAL0 with PID 7200 (D:\MyProject\seal-ms\ms-cv3\build\classes\java\main started by EDY in D:\MyProject\seal-ms) 2025-12-08 09:12:28.344 [main] INFO io.tubo.cv3.Cv3Application - No active profile set, falling back to default profiles: default 2025-12-08 09:12:30.613 [main] INFO org.apache.coyote.http11.Http11NioProtocol - Initializing ProtocolHandler ["http-nio-9000"] 2025-12-08 09:12:30.624 [main] INFO org.apache.catalina.core.StandardService - Starting service [Tomcat] 2025-12-08 09:12:30.625 [main] INFO org.apache.catalina.core.StandardEngine - Starting Servlet engine: [Apache Tomcat/9.0.19] 2025-12-08 09:12:31.097 [main] INFO org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/] - Initializing Spring embedded WebApplicationContext 2025-12-08 09:12:31.349 [main] INFO com.zaxxer.hikari.HikariDataSource - SpringBootJPAHikariCP - Starting... 2025-12-08 09:12:31.579 [main] INFO com.zaxxer.hikari.HikariDataSource - SpringBootJPAHikariCP - Start completed. 2025-12-08 09:12:31.833 [main] INFO org.hibernate.Version - HHH000412: Hibernate Core {5.3.10.Final} 2025-12-08 09:12:31.837 [main] INFO org.hibernate.cfg.Environment - HHH000206: hibernate.properties not found 2025-12-08 09:12:32.085 [main] INFO org.hibernate.annotations.common.Version - HCANN000001: Hibernate Commons Annotations {5.0.4.Final} 2025-12-08 09:12:32.357 [main] INFO org.hibernate.dialect.Dialect - HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect 2025-12-08 09:12:34.231 [main] INFO com.zaxxer.hikari.HikariDataSource - SpringBootJPAHikariCP - Shutdown initiated... 2025-12-08 09:12:34.240 [main] INFO com.zaxxer.hikari.HikariDataSource - SpringBootJPAHikariCP - Shutdown completed. 2025-12-08 09:12:34.241 [main] INFO org.apache.catalina.core.StandardService - Stopping service [Tomcat] 这段日志报错原因是什么,怎么解决
最新发布
12-09
2025-05-31 21:13:59.595 [main] INFO com.gk.study.MySpringApplication - Starting MySpringApplication using Java 1.8.0_332 on mac.local with PID 6567 (/Users/qinchuanlin/Downloads/video-demand-website-master/server/target/classes started by qinchuanlin in /Users/qinchuanlin/Downloads/video-demand-website-master/server) 2025-05-31 21:13:59.598 [main] INFO com.gk.study.MySpringApplication - No active profile set, falling back to default profiles: default 2025-05-31 21:14:00.287 [main] INFO org.apache.coyote.http11.Http11NioProtocol - Initializing ProtocolHandler ["http-nio-9100"] 2025-05-31 21:14:00.287 [main] INFO org.apache.catalina.core.StandardService - Starting service [Tomcat] 2025-05-31 21:14:00.287 [main] INFO org.apache.catalina.core.StandardEngine - Starting Servlet engine: [Apache Tomcat/9.0.53] 2025-05-31 21:14:00.320 [main] INFO o.a.c.c.ContainerBase.[Tomcat].[localhost].[/api] - Initializing Spring embedded WebApplicationContext 2025-05-31 21:14:00.521 [main] WARN c.b.mybatisplus.core.metadata.TableInfoHelper - Can not find table primary key in Class: "java.lang.Object". 2025-05-31 21:14:00.522 [main] WARN c.b.mybatisplus.core.injector.DefaultSqlInjector - class java.lang.Object ,Not found @TableId annotation, Cannot use Mybatis-Plus &#39;xxById&#39; Method. _ _ |_ _ _|_. ___ _ | _ | | |\/|_)(_| | |_\ |_)||_|_\ / | 3.5.2 2025-05-31 21:14:00.603 [main] INFO com.alibaba.druid.pool.DruidDataSource - {dataSource-0} closing ... 2025-05-31 21:14:00.605 [main] INFO org.apache.catalina.core.StandardService - Stopping service [Tomcat]服务无法启动
06-02
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

烤鸭的世界我们不懂

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值