当前位置: 首页 > 知识库问答 >
问题:

为什么Spring开机总是在两小时内关机

齐昊焱
2023-03-14
  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.1.9.RELEASE)

2016-03-17 17:41:54.784  INFO 20016 --- [           main] com.hello.bibi.App                 : Starting App on iZ947723zxnZ with PID 20016 (/root/projects/taomi-back/bibi-0.0.1-SNAPSHOT.jar started by root in /root/projects/taomi-back)
2016-03-17 17:41:54.850  INFO 20016 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5cf0ac6e: startup date [Thu Mar 17 17:41:54 CST 2016]; root of context hierarchy
2016-03-17 17:41:56.477  INFO 20016 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'beanNameViewResolver': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false;factoryBeanName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
2016-03-17 17:41:57.557  INFO 20016 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'databaseConfig4Bibi' of type [class com.hello.bibi.config.DatabaseConfig4Bibi$$EnhancerBySpringCGLIB$$5c20f114] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-03-17 17:41:58.434  INFO 20016 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'dataSource4bibi' of type [class com.jolbox.bonecp.BoneCPDataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-03-17 17:41:59.194  INFO 20016 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'sqlSessionFactory4bibi' of type [class org.apache.ibatis.session.defaults.DefaultSqlSessionFactory] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-03-17 17:41:59.278  INFO 20016 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'spiderJdCommentIncrMapper' of type [class org.mybatis.spring.mapper.MapperFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-03-17 17:41:59.287  INFO 20016 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'spiderJdCommentMapper' of type [class org.mybatis.spring.mapper.MapperFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-03-17 17:41:59.294  INFO 20016 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'spiderJdItemMapper' of type [class org.mybatis.spring.mapper.MapperFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-03-17 17:41:59.300  INFO 20016 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'userMapper' of type [class org.mybatis.spring.mapper.MapperFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-03-17 17:41:59.402  INFO 20016 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$364a7a87] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-03-17 17:41:59.436  INFO 20016 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'transactionAttributeSource' of type [class org.springframework.transaction.annotation.AnnotationTransactionAttributeSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-03-17 17:41:59.452  INFO 20016 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'transactionInterceptor' of type [class org.springframework.transaction.interceptor.TransactionInterceptor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-03-17 17:41:59.461  INFO 20016 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.config.internalTransactionAdvisor' of type [class org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-03-17 17:41:59.992  INFO 20016 --- [           main] .t.TomcatEmbeddedServletContainerFactory : Server initialized with port: 8090
2016-03-17 17:42:00.261  INFO 20016 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
2016-03-17 17:42:00.263  INFO 20016 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/7.0.56
2016-03-17 17:42:00.420  INFO 20016 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2016-03-17 17:42:00.420  INFO 20016 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 5574 ms
2016-03-17 17:42:01.119  INFO 20016 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean        : Mapping servlet: 'dispatcherServlet' to [/]
2016-03-17 17:42:01.124  INFO 20016 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2016-03-17 17:42:01.519  INFO 20016 --- [           main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2016-03-17 17:42:01.534  INFO 20016 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2016-03-17 17:42:01.648  INFO 20016 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate Core {4.3.7.Final}
2016-03-17 17:42:01.651  INFO 20016 --- [           main] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
2016-03-17 17:42:01.653  INFO 20016 --- [           main] org.hibernate.cfg.Environment            : HHH000021: Bytecode provider name : javassist
2016-03-17 17:42:01.991  INFO 20016 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
2016-03-17 17:42:02.076  INFO 20016 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2016-03-17 17:42:02.155  INFO 20016 --- [           main] o.h.h.i.ast.ASTQueryTranslatorFactory    : HHH000397: Using ASTQueryTranslatorFactory
2016-03-17 17:42:02.534  INFO 20016 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-03-17 17:42:02.986  INFO 20016 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/bibi/commentIncrTop],methods=[],params=[],headers=[],consumes=[],produces=[application/json;charset=UTF-8],custom=[]}" onto public java.lang.String com.hello.bibi.controller.BibiController.commentIncrTop(javax.servlet.http.HttpServletRequest,int,int)
2016-03-17 17:42:02.986  INFO 20016 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/bibi/priceReduce],methods=[],params=[],headers=[],consumes=[],produces=[application/json;charset=UTF-8],custom=[]}" onto public java.lang.String com.hello.bibi.controller.BibiController.priceReduce(javax.servlet.http.HttpServletRequest,int,int)
2016-03-17 17:42:02.987  INFO 20016 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/bibi/categoryTree],methods=[],params=[],headers=[],consumes=[],produces=[application/json;charset=UTF-8],custom=[]}" onto public java.lang.String com.hello.bibi.controller.BibiController.categoryTree(javax.servlet.http.HttpServletRequest)
2016-03-17 17:42:02.992  INFO 20016 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/taomi/collect],methods=[GET],params=[],headers=[],consumes=[],produces=[application/json;charset=UTF-8],custom=[]}" onto public void com.hello.bibi.controller.CollectController.itemInfo(java.lang.String,java.lang.String,java.lang.String)
2016-03-17 17:42:02.994  INFO 20016 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[//testpage],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.hello.bibi.controller.HelloWorldController.helloWorld()
2016-03-17 17:42:02.994  INFO 20016 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[//test],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.hello.bibi.controller.HelloWorldController.helloWorld2(java.lang.String,int)
2016-03-17 17:42:02.994  INFO 20016 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[//test2/{id}],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.hello.bibi.controller.HelloWorldController.test2(long)
2016-03-17 17:42:02.994  INFO 20016 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[//test3/{str}],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.hello.bibi.controller.HelloWorldController.test3(java.lang.String)
2016-03-17 17:42:02.994  INFO 20016 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[//test4],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.hello.bibi.controller.HelloWorldController.test4(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2016-03-17 17:42:02.995  INFO 20016 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[//test5/{id}/vv/{str}],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.hello.bibi.controller.HelloWorldController.test5(java.lang.String,java.lang.String)
2016-03-17 17:42:02.995  INFO 20016 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[//user],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.hello.bibi.controller.HelloWorldController.user()
2016-03-17 17:42:02.995  INFO 20016 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/user/test],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.hello.bibi.controller.UserController.isNameExist(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2016-03-17 17:42:02.998  INFO 20016 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],methods=[],params=[],headers=[],consumes=[],produces=[text/html],custom=[]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest)
2016-03-17 17:42:02.998  INFO 20016 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2016-03-17 17:42:03.043  INFO 20016 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-03-17 17:42:03.043  INFO 20016 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-03-17 17:42:03.526  INFO 20016 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2016-03-17 17:42:03.528  INFO 20016 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'dataSource4bibi' has been autodetected for JMX exposure
2016-03-17 17:42:03.532  INFO 20016 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Located MBean 'dataSource4bibi': registering with JMX server as MBean [com.jolbox.bonecp:name=dataSource4bibi,type=BoneCPDataSource]
2016-03-17 17:42:03.729  INFO 20016 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8090/http
2016-03-17 17:42:03.731  INFO 20016 --- [           main] com.hello.bibi.App                 : Started App in 10.01 seconds (JVM running for 10.872)
2016-03-17 17:42:04.217  INFO 20016 --- [nio-8090-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring FrameworkServlet 'dispatcherServlet'
2016-03-17 17:42:04.217  INFO 20016 --- [nio-8090-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started
2016-03-17 17:42:04.243  INFO 20016 --- [nio-8090-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 26 ms
2016-03-17 20:01:59.081  INFO 20016 --- [       Thread-2] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5cf0ac6e: startup date [Thu Mar 17 17:41:54 CST 2016]; root of context hierarchy
2016-03-17 20:01:59.085  INFO 20016 --- [       Thread-2] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown
2016-03-17 20:01:59.090  INFO 20016 --- [       Thread-2] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2016-03-17 20:01:59.092  INFO 20016 --- [       Thread-2] com.jolbox.bonecp.BoneCP                 : Shutting down connection pool...
2016-03-17 20:01:59.101  INFO 20016 --- [       Thread-2] com.jolbox.bonecp.BoneCP                 : Connection pool has been shutdown.

App.java

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
@ComponentScan
@EnableAutoConfiguration
public class App {
    public static void main( String[] args ) {
        SpringApplication.run(App.class);
    }
}

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.hello.bibi</groupId>
    <artifactId>bibi</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>bibi</name>
    <url>http://maven.apache.org</url>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.1.9.RELEASE</version>
    </parent>

    <properties>
        <main.basedir>${basedir}/../..</main.basedir>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <mybatis.version>3.2.2</mybatis.version>
        <mybatisspring.version>1.2.0</mybatisspring.version>
        <app.mainClass>com.hello.bibi.App</app.mainClass>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
            <version>${mybatis.version}</version>
        </dependency>
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis-spring</artifactId>
            <version>${mybatisspring.version}</version>
        </dependency>
        <dependency>
            <groupId>com.jolbox</groupId>
            <artifactId>bonecp</artifactId>
            <version>0.8.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <mainClass>${app.mainClass}</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

共有1个答案

葛鸿轩
2023-03-14

请按以下方式运行应用程序:

nohup java -jar xxx.jar > output.log 2>&1&

来自维基百科:

nohup是一个忽略HUP(挂起)信号的POSIX命令。按照惯例,HUP信号是终端警告相关进程注销的方式。如果还没有被重定向,那么通常会转到终端的输出会转到一个名为nohup.out的文件中。

@Bean
public CountDownLatch closeLatch() {
    return new CountDownLatch(1);
}

public static void main(String... args) throws InterruptedException {
    ApplicationContext ctx = SpringApplication.run(MyApp.class, args); 

    final CountDownLatch closeLatch = ctx.getBean(CountDownLatch.class);
    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
            closeLatch.countDown();
        }
    }); 
    closeLatch.await();
}
kill <PID>
 类似资料:
  • 这个问题解决了。请看下面的核对答案。 注入点有以下注释:-@org.springframework.beans.factory.annotation.autowired(required=true) 行动: 考虑在您的配置中定义一个类型为'DAO.UserRepository'的bean。 进程结束,退出代码为%1

  • 问题内容: 我读过,我们应该始终在循环内调用a : 它可以正常工作而没有循环,那为什么呢? 问题答案: 你不仅需要循环它,还需要在循环中检查条件。Java不能保证仅通过notify()/ notifyAll()调用或正确的notify()/ notifyAll()调用来唤醒你的线程。由于此属性,无环版本可能在你的开发环境上工作,而在生产环境上意外失败。 例如,你正在等待一些东西: 邪恶的线程出现了

  • 我正在尝试了解Spring Boot如何关闭分布式Hazelcast缓存。当我连接然后关闭第二个实例时,我会得到以下日志: 似乎当我关闭它时,第二个实例并没有向第一个实例报告它正在正确关闭。我们在它无法连接到它几秒钟后收到警告,因此从集群中删除。 它表示它正在尝试运行一个关闭挂钩,但它所做的最后一个报告仍然是“活动的”,并且它从来没有像本文中提到的那样转到“关机”或“关机”。 pom。xml 只是

  • 这是我的第一个Spring Boot代码。不幸的是,它总是关机。我原本期望它能持续运行,这样我的web客户端就能从浏览器中获取一些数据。 附注。Build.Gradle是错误。 一旦我用粗体取下上面那一行,一切都正常了。我的应用程序上下文现在是正确的。谢谢戴夫

  • 我已经下载了包含eclipse Juno的adt包,但是当我解压缩它时,不断得到一个错误“错误已经发生,请查看日志文件”请帮助我解决这个问题。 日志文件: !条目org.eclipse.osgi 4 0 202 1-05-25 10:58:03.222!消息应用程序错误!堆栈1 java.lang.IllegalStateException:无法获取应用程序服务。确保解析并启动了org.eclip

  • 本文向大家介绍Hbase内部是什么机制?相关面试题,主要包含被问及Hbase内部是什么机制?时的应答技巧和注意事项,需要的朋友参考一下 解答: 在HMaster、RegionServer内部,创建了RpcServer实例,并与Client三者之间实现了Rpc调用,HBase0.95内部引入了Google-Protobuf作为中间数据组织方式,并在Protobuf提供的Rpc接口之上,实现了基于服务