美文网首页
第六章:springboot2使用undertow

第六章:springboot2使用undertow

作者: 菜出意料 | 来源:发表于2023-12-06 14:09 被阅读0次

1. 替换tomcat

compile('org.springframework.boot:spring-boot-starter-web') {
    exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
}

compile ('org.springframework.boot:spring-boot-starter-undertow') {
    // 集成org.springframework.boot:spring-boot-starter-websocket时需要排除以下jar包
    exclude group: 'io.undertow', module: 'undertow-websockets-jsr'
}
compile ('org.springframework.boot:spring-boot-starter-websocket')

2. yaml配置

server:
  http2:
    enabled: true
  undertow:
    buffer-size: 1024
    # 是否分配的直接内存(NIO直接分配的堆外内存)
    direct-buffers: true
    threads:
      # 默认设置每个CPU核心一个线程 比如 四核的服务器  则配置4
      io: 8
      # 默认值是IO线程数 * 8   高并发的服务可以根据并发情况调大一些
      worker: 256

相关文章

网友评论

      本文标题:第六章:springboot2使用undertow

      本文链接:https://www.haomeiwen.com/subject/hwejgdtx.html