[英]java SpringBoot jar crashes on CentOS
I have a very simple SpringBoot application which implements a simple Rest API. 我有一个非常简单的SpringBoot应用程序,它实现了一个简单的Rest API。
This is the way I start it: 这是我启动的方式:
package API;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Main {
public static void main(String args[]){
SpringApplication.run(Main.class);
}
}
The controller is placed in the same package as this one (the API
package). 控制器与此包放置在同一包中(
API
包)。
This is my maven file: 这是我的Maven文件:
<?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>HadoopDriver</groupId>
<artifactId>HadoopDriver</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
</parent>
<properties>
<tomcat.version>8.0.30</tomcat.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.0.2.RELEASE</version>
<configuration>
<executable>true</executable>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>5.0.6.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-sns</artifactId>
<version>1.11.338</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-yarn-client</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.0.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.0.2.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.2</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<version>2.6.1</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-hdfs</artifactId>
<version>2.6.1</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<repositories>
<repository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>repository.spring.release</id>
<name>Spring GA Repository</name>
<url>https://repo.spring.io/plugins-release/</url>
</pluginRepository>
</pluginRepositories>
</project>
I develop this app in IntelliJ Idea, on macOS and I generate a JAR that I place on a Cent OS (EC2) machine and I want to run it from there. 我在macOS上的IntelliJ Idea中开发了该应用程序,并生成了JAR,并将其放置在Cent OS(EC2)机器上,并希望从那里运行它。
I generate the manifest file like that: File -> Project Structure -> Artifacts -> + -> JAR -> From Modules with dependencies -> select the Main class -> change the directory of the META-INF to /resources instead of /java -> Apply -> OK . 我生成清单文件,如下所示: File-> Project Structure-> Artifacts-> +-> JAR->从具有依赖项的模块中->选择Main类->将META-INF的目录更改为/ resources而不是/ java->应用->确定
The I go on Build -> Build Artifacts -> Build and then I get my JAR that is placed in the /out/artifacts/project_jar
folder. 我继续进行Build-> Build Artifacts-> Build ,然后将我的JAR放在
/out/artifacts/project_jar
文件夹中。
I upload this jar to the Cent OS machine and when I try to run it I get the following output: 我将此罐子上传到Cent OS计算机,当我尝试运行它时,得到以下输出:
user@host>
log4j:WARN No appenders could be found for logger (org.springframework.web.context.support.StandardServletEnvironment).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot ::
user@host>
I get no error message, no nothing. 我没有收到任何错误消息,什么也没有。 I don't know where to look for errors, I don't have any clue on how to solve this issue.
我不知道在哪里寻找错误,我不知道如何解决这个问题。
Please tell me at least where to look, how can I diagnose this problem because I'm trying for a lot of time with no result. 请至少告诉我在哪里看,如何诊断这个问题,因为我花了很多时间都没有结果。
You don't want to use Log4J in your application, for a couple of reasons: 由于以下两个原因,您不想在应用程序中使用Log4J:
In your case, you may not be getting enough detail in your logs. 就您而言,您的日志中可能没有足够的详细信息。 Crank up the verbosity by adding this to your
application.properties
file: 通过将其添加到
application.properties
文件来提高详细程度:
logging.level.org.springframework=debug
This will allow you to see debug logs in stdout from everything living underneath org.springframework
. 这将使您能够从
org.springframework
下的所有内容查看stdout中的调试日志。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.