在AWS ec2实例中部署Spring Boot war

时间:2018-04-06 18:45:42

标签: maven tomcat spring-boot amazon-ec2 deployment

我正在尝试在aws ec2实例上的Apache Tomcat / 8.5.29中部署spring boot应用程序作为war文件。如果我将它粘贴到本地机器的tomcat webapps文件夹并重新启动本地的机器tomcat服务器,那么相同的war文件工作正常,部署的war文件会自动解压缩,并且应用程序可以在本地访问。

我在本地机器和ec2实例上使用相同版本的java“1.8”。

但是当我在aws上尝试相同并重新启动tomcat时,war文件没有被提取并且无法访问。我还检查了服务器上的日志文件,可能有一些错误,但我发现了空日志文件。我正在'var / lib / tomcat'文件夹中部署war文件。

由于我已经在同一个aws的tomcat上部署了angular 5应用程序的构建,它也能正常工作。

这是我的代码

1.ScApplication.java

@SpringBootApplication
public class ScApplication extends SpringBootServletInitializer{

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    return application.sources(ScApplication.class);
}

     public static void main(String[] args) {
         SpringApplication.run(ScApplication.class, args);
    }
}

2.pom.xml

http://maven.apache.org/xsd/maven-4.0.0.xsd">     4.0.0     com.student.corner     SC     0.0.1-SNAPSHOT     战

<name>SC</name>
<description>Student Corner</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.9.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</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-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-social-facebook</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-social-linkedin</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.jsonwebtoken</groupId>
        <artifactId>jjwt</artifactId>
        <version>0.7.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.springframework.mobile/spring-mobile-device -->
    <dependency>
        <groupId>org.springframework.mobile</groupId>
        <artifactId>spring-mobile-device</artifactId>
        <version>1.1.5.RELEASE</version>
    </dependency>    
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

0 个答案:

没有答案