该应用程序在我的IDE(IntelliJ社区版)中本地运行良好。我可以运行该应用程序,进入浏览器,输入localhost:8080
,它显示出“ Hello World”
在AWS上,我转到“软件配置”部分,并添加了一个环境变量SERVER_PORT
并将其设置为8080。
我相信当系统提示我要哪种类型的beantalk配置时,我选择了Tomcat。
这是我的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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.9.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.lizardgizzards</groupId>
<artifactId>langsite</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>langsite</name>
<description>Demo project for Spring Boot</description>
<packaging>war</packaging>
<properties>
<java.version>11</java.version>
<start-class>com.lizardgizzards.langsite.LangsiteApplication</start-class>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
我找到了this answer,并按照那里的指示进行操作,所以现在我的主班级看起来像这样:
package com.lizardgizzards.langsite;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication
@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
public class LangsiteApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(LangsiteApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(LangsiteApplication.class, args);
}
}
我将粘贴日志,但超出堆栈溢出的字符数限制。我在日志输出中做了ctrl+f
,并搜索了“错误”,“严重”和“致命”,但是没有看到任何结果。
有一些警告,例如:
[Sun Oct 13 18:26:14.321734 2019] [ssl:warn] [pid 3396:tid 139962572781632] AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=64m; support was removed in 8.0
[Sun Oct 13 18:41:58.389785 2019] [proxy:warn] [pid 4934:tid 140166163138304] [client 178.73.215.171:54277] AH01092: no HTTP 0.9 request (with no host line) on incoming request and preserve host set forcing hostname to be ip-172-31-18-139.us-west-1.compute.internal for uri /
13-Oct-2019 18:36:07.679 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent 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]
生成战争文件时,我使用以下maven命令:mvn clean install spring-boot:repackage
答案 0 :(得分:1)
有点荒谬……但这是解决问题的方法:
我更改了Java版本以使其与AWS上的Java版本匹配:
<java.version>1.8</java.version>