我在生产和阶段A上以jar形式启动了spring boot应用程序。它运行了一段时间,然后突然注销了JMX并关闭了。但是,它不会在其他环境(例如QA和阶段B)上失败。所有在Linux上运行的环境。我使用的命令是
nohup xxx/java/java_1.8/bin/java-javaagent:xxx/monitoring/newrelic/services/xxx/newrelic.jar -Dserver.port=8201 -jar /b001/app/services/xxx/xxx.jar >> xxx/logs/xxx/xxx.log 2>&1 & port=8201
日志上没有例外,但似乎已调用了关闭挂钩。日志包含:
2018-12-31 14:11:01.207 INFO 7653 --- [ Thread-19] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@30c31dd7: startup date [Mon Dec 31 04:53:50 CST 2018]; root of context hierarchy
2018-12-31 14:11:01.211 INFO 7653 --- [ Thread-19] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
Application.java
@ComponentScan(basePackages = { "com.xxx.xxx" })
@EntityScan(basePackages = "com.xxx.xxx")
@EnableAutoConfiguration
@EnableWebMvc
@SpringBootApplication
@PropertySources({ @PropertySource(value = "file:/xxx/xxx.properties",
ignoreResourceNotFound = true )
,@PropertySource(value = "file:xxx/xxx.properties", ignoreResourceNotFound
= true)
,@PropertySource(value = "application.properties")})
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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.xxx.xxx</groupId>
<artifactId>xxx</artifactId>
<packaging>jar</packaging>
<name>xxx</name>
<description>xxx API Application</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<relativePath/> <!-- lookup parent from repository -->
<version>1.5.8.RELEASE</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<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-aop</artifactId>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20160810</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
application.properties:
endpoints.metrics.sensitive=false
endpoints.metrics.enabled=true