【问题标题】:Smaller deps for spring stomp websocket client用于 spring stomp websocket 客户端的较小的 deps
【发布时间】:2021-12-06 14:36:43
【问题描述】:

我在使用StandardWebSocketClient 的Java 客户端上使用spring stomp websocket,很像这个例子:

https://www.baeldung.com/websockets-api-java-spring-client

使用spring-boot-starter-websocketmaven dep添加了太多客户端不需要的dep,于是想出了:

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-websocket</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-websocket</artifactId>
        <version>${tomcat.embed.websocket.version}</version>
        <scope>compile</scope>
        <exclusions>
            <exclusion>
                <artifactId>tomcat-annotations-api</artifactId>
                <groupId>org.apache.tomcat</groupId>
            </exclusion>
        </exclusions>
    </dependency>

tomcat-embed-websocket 是提供javax.websocket 实现。但它相当大,因为它添加了tomcat-embed-core

我尝试使用Tyrus,但不知道要添加哪些部门。

Tyrus 会更小吗?如何只添加客户端?

【问题讨论】:

    标签: spring-websocket tyrus


    【解决方案1】:

    Tyrus 独立客户端捆绑包可能是最好的开始

    https://repo1.maven.org/maven2/org/glassfish/tyrus/bundles/tyrus-standalone-client/2.0.1/

    我不确定 tomcat embed 内核有多大,但这不是一个小库,它有 ~2.2 MB。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-03-21
      • 2016-12-22
      • 2015-03-25
      • 1970-01-01
      • 2020-10-08
      • 2015-04-17
      • 1970-01-01
      相关资源
      最近更新 更多