gpt4 book ai didi

java - Spring Boot Java后端应用程序进程被杀死

转载 作者:行者123 更新时间:2023-12-01 18:41:58 27 4
gpt4 key购买 nike

我已经使用 mvn package 打包了 Spring Boot Rest 后端。

当我使用 java -jar ... 在服务器上运行 jar 时,应用程序启动并在几秒钟后被终止。

我还在 Linux top View 上看到 java 进程占用了超过 300% 的 CPU。这可能是进程被杀死的原因吗?如果是,我能做什么?

我的 Spring Boot 应用程序不是很大。事实上它几乎是空的。

日志:

  .   ____          _            __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.2.RELEASE)

2020-01-26 07:40:36.423 INFO 8144 --- [ main] d.c.c.CarorderprocessApplication : Starting CarorderprocessApplication v0.0.1-SNA
PSHOT on dedi1055.your-server.de with PID 8144 (/usr/www/users/waqfek/software_backend/carorderprocess-0.0.1-SNAPSHOT.jar started by waqfek in /us
r/www/users/waqfek/software_backend)
2020-01-26 07:40:36.426 INFO 8144 --- [ main] d.c.c.CarorderprocessApplication : No active profile set, falling back to default
profiles: default
2020-01-26 07:40:36.487 INFO 8144 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servle
t.context.AnnotationConfigServletWebServerApplicationContext@5cbc508c: startup date [Sun Jan 26 07:40:36 CET 2020]; root of context hierarchy
2020-01-26 07:40:37.614 INFO 8144 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotati
on.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerB
ySpringCGLIB$$d289c8bd] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-01-26 07:40:37.915 INFO 8144 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8081 (http)
2020-01-26 07:40:37.939 INFO 8144 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-01-26 07:40:37.940 INFO 8144 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.31
2020-01-26 07:40:37.949 INFO 8144 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library whi
ch allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib/x86_64-lin
ux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib]
2020-01-26 07:40:38.014 INFO 8144 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationCon
text
2020-01-26 07:40:38.014 INFO 8144 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization com
pleted in 1530 ms
2020-01-26 07:40:38.159 INFO 8144 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to:
[/*]
2020-01-26 07:40:38.159 INFO 8144 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [
/*]
2020-01-26 07:40:38.159 INFO 8144 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to:
[/*]
2020-01-26 07:40:38.159 INFO 8144 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*
]
2020-01-26 07:40:38.160 INFO 8144 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to
: [/*]
2020-01-26 07:40:38.160 INFO 8144 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2020-01-26 07:40:38.302 INFO 8144 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-01-26 07:40:38.306 WARN 8144 --- [ main] com.zaxxer.hikari.util.DriverDataSource : Registered driver with driverClassName=com.mysql.jdbc.Driver was not found, trying direct instantiation.
2020-01-26 07:40:38.491 INFO 8144 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-01-26 07:40:38.534 INFO 8144 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2020-01-26 07:40:38.548 INFO 8144 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2020-01-26 07:40:38.625 INFO 8144 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.2.17.Final}
2020-01-26 07:40:38.627 INFO 8144 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2020-01-26 07:40:38.661 INFO 8144 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2020-01-26 07:40:38.824 INFO 8144 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2020-01-26 07:40:39.086 INFO 8144 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-01-26 07:40:39.172 INFO 8144 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2020-01-26 07:40:39.406 INFO 8144 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@5cbc508c: startup date [Sun Jan 26 07:40:36 CET 2020]; root of context hierarchy
2020-01-26 07:40:39.444 WARN 8144 --- [ main] aWebConfiguration$JpaWebMvcConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2020-01-26 07:40:39.492 INFO 8144 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2020-01-26 07:40:39.494 INFO 8144 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2020-01-26 07:40:39.526 INFO 8144 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2020-01-26 07:40:39.526 INFO 8144 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2020-01-26 07:40:39.867 INFO 8144 --- [ main] .s.s.UserDetailsServiceAutoConfiguration :

Using generated security password: 8167df1e-24d1-4ebf-bb03-53e2385a1229

2020-01-26 07:40:40.030 INFO 8144 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: org.springframework.security.web.util.matcher.AnyRequestMatcher@1, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@d2de489, org.springframework.security.web.context.SecurityContextPersistenceFilter@28cda624, org.springframework.security.web.header.HeaderWriterFilter@5340477f, org.springframework.security.web.csrf.CsrfFilter@6f15d60e, org.springframework.security.web.authentication.logout.LogoutFilter@71687585, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@66ea810, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter@5276d6ee, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@2f953efd, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@7eecb5b8, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@475c9c31, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@14bdbc74, org.springframework.security.web.session.SessionManagementFilter@7139992f, org.springframework.security.web.access.ExceptionTranslationFilter@446a1e84, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@169bb4dd]
2020-01-26 07:40:40.112 INFO 8144 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2020-01-26 07:40:40.113 INFO 8144 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'dataSource' has been autodetected for JMX exposure
2020-01-26 07:40:40.118 INFO 8144 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located MBean 'dataSource': registering with JMX server as MBean [com.zaxxer.hikari:name=dataSource,type=HikariDataSource]
2020-01-26 07:40:40.142 INFO 8144 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8081 (http) with context path ''
2020-01-26 07:40:40.145 INFO 8144 --- [ main] d.c.c.CarorderprocessApplication : Started CarorderprocessApplication in 4.002 seconds (JVM running for 4.521)
Killed

...

top - 08:51:43 up 137 days, 11:30,  2 users,  load average: 0.86, 0.39, 0.30
Tasks: 4 total, 1 running, 3 sleeping, 0 stopped, 0 zombie
%Cpu(s): 30.7 us, 0.9 sy, 0.0 ni, 68.1 id, 0.2 wa, 0.0 hi, 0.1 si, 0.0 st
KiB Mem : 16119112 total, 4416660 free, 7332300 used, 4370152 buff/cache
KiB Swap: 4194300 total, 3625572 free, 568728 used. 8221460 avail Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
20338 waqfek 20 0 7069792 299952 16808 S 247.5 1.9 0:07.45 java
16765 waqfek 20 0 38960 3032 2704 R 0.0 0.0 0:00.57 top
27373 waqfek 20 0 14092 3600 3048 S 0.0 0.0 0:00.16 bash
28746 waqfek 20 0 14072 3524 2988 S 0.0 0.0 0:00.00 bash

我的项目中只有三个文件:

1:

package ...

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;


@SpringBootApplication
public class CarorderprocessApplication {
public static void main(String[] args) {
SpringApplication.run(CarorderprocessApplication.class, args);
}
}
  • 然后我有 application.properties 文件,其中包含数据库连接和端口的信息。

  • pom.xml:

    https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.springframework.boot spring-boot-starter-父级 2.0.2.发布 取消计数和护理 送货流程 0.0.1-快照 送货流程 Spring Boot 演示项目

    <dependencyManagement>
    <dependencies>

    </dependencies>
    </dependencyManagement>


    <properties>
    <java.version>1.8</java.version>
    </properties>

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

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

    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-jdbc</artifactId>
    <version>2.2.1.RELEASE</version>
    </dependency>

    <dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>8.0.17</version>
    </dependency>

    <dependency>
    <groupId>javax.persistence</groupId>
    <artifactId>persistence-api</artifactId>
    <version>1.0.2</version>
    </dependency>

    <dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter-api</artifactId>
    <version>5.5.2</version>
    <scope>test</scope>
    </dependency>
    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-security</artifactId>
    </dependency>

    </dependencies>

    <build>
    <plugins>
    <plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    </plugin>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <executions>
    <execution>
    <id>compile</id>
    <phase>compile</phase>
    <goals>
    <goal>compile</goal>
    </goals>
    </execution>
    </executions>
    </plugin>
    </plugins>
    </build>

  • 最佳答案

    一些需要检查的想法:

    1. 尝试以分离方式运行:java -jar yourapp.jar &
    2. 尝试(仅一次)在 root 下运行
    3. 检查日志:journalctl -ex,了解到底是谁杀死了您的应用程序的详细信息。

    根据结果,可以计划后续步骤 - 通常要调整哪些设置。

    关于java - Spring Boot Java后端应用程序进程被杀死,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59916084/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com