若依前后端分离,ruoyi-vue jar包更改成war包发布 Websocket 配置

web模块下的pom文件

1.替换打包方式

    <!--<packaging>jar</packaging>-->
    <packaging>war</packaging>

2.如果引用第三方jar包,打入webResources(选做)

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <webResources>
                        <webResource>
                            <directory>${pom.basedir}/src/main/resources/lib/</directory>
                            <targetPath>WEB-INF/lib/</targetPath>
                            <includes>
                                <include>**/*.jar</include>
                            </includes>
                        </webResource>
                    </webResources>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                    <warName>${project.artifactId}</warName>
                </configuration>
            </plugin>

framework下的pom文件

3.排除jar包中的内置tomcat

        <!-- SpringBoot Web容器 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <!--            war包发布        -->
            <!--            排除jar包中的内置tomcat-->
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

4.WebSocket需要的API

        <!-- 排除jar包中的内置tomcat,WebSocket需要的API-->
        <dependency>
            <groupId>javax.websocket</groupId>
            <artifactId>javax.websocket-api</artifactId>
            <version>1.1</version>
            <scope>provided</scope>
        </dependency>

ServerEndpointExporter交由Tomcat管理

注释ServerEndpointExporter

package com.huida.framework.websocket;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;

/**
 * websocket 配置
 *
 * @author huida
 */
//@Configuration
//public class WebSocketConfig
//{
//    @Bean
//    public ServerEndpointExporter serverEndpointExporter()
//    {
//        return new ServerEndpointExporter();
//    }
//}

相关推荐

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-13 22:52:07       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-13 22:52:07       100 阅读
  3. 在Django里面运行非项目文件

    2024-03-13 22:52:07       82 阅读
  4. Python语言-面向对象

    2024-03-13 22:52:07       91 阅读

热门阅读

  1. c语言之函数声明

    2024-03-13 22:52:07       46 阅读
  2. 题目 3150: 冶炼金属

    2024-03-13 22:52:07       42 阅读
  3. SQL 中 IN 与 <= 且 >= 的效率比较

    2024-03-13 22:52:07       47 阅读
  4. 职业规划随笔

    2024-03-13 22:52:07       45 阅读
  5. k8s之配置springboot项目

    2024-03-13 22:52:07       42 阅读
  6. go优雅重试

    2024-03-13 22:52:07       45 阅读