作为Java应用程序运行,但不在服务器上运行

时间:2019-05-14 08:09:32

标签: spring maven web dynamic

您好,我从互联网上获得了一些网络聊天代码。该项目作为Java应用程序运行,但不在服务器上(在动态Web项目中)运行。如何使它在服务器上工作?

一些有用的信息: 弦靴 Maven, Apache tomcat, 动态网络项目

POM:

<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>chat</groupId>
<artifactId>chat</artifactId>
<version>0.0.1-SNAPSHOT</version>

<packaging>war</packaging>

<name>spring-boot-websocket-chat</name>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.4.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-websocket</artifactId>
    </dependency>

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

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

主类:

package com.javainuse;

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

@SpringBootApplication
public class SpringBootChatApplication {

public static void main(String[] args) {

    SpringApplication.run(
             SpringBootChatApplication.class , args);
}
}

1 个答案:

答案 0 :(得分:0)

将您的应用程序包装更改为war! <packaging>war</packaging> 现在您可以在服务器中部署战争了