鍍金池/ 問答/Java  Linux  網(wǎng)絡(luò)安全/ springboot2和eureka整合選擇netty作為啟動(dòng)容器

springboot2和eureka整合選擇netty作為啟動(dòng)容器

最近剛上手springboot2,有很多大更新,準(zhǔn)備研究一下spring-webflux使用內(nèi)置的netty容器作為啟動(dòng)容器。
雖然剛上手遇到些坑,但是還算是如愿看到效果了。這是我整合spring-cloud-starter-netflix-eureka-server之前的pom

    <dependencies>
        
        <!-- Spring Boot Web Flux 依賴 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-webflux</artifactId>
        </dependency>
        
    </dependencies>

然后我想繼續(xù)引入spring-cloud,踩了些坑也算運(yùn)行起來了。但是一不留神看到啟動(dòng)日志中啟動(dòng)容器變?yōu)榱藅omcat,試了官方設(shè)置方式,引入spring-boot-starter-reactor-netty無效,還是tomcat啟動(dòng)

clipboard.png
這是我引用之后的pom

    <dependencies>
        
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
        </dependency>
        
        <!-- Spring Boot Web Flux 依賴 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-webflux</artifactId>
        </dependency>
        <!-- 使用netty作為啟動(dòng)容器 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-reactor-netty</artifactId>
        </dependency>
        
    </dependencies>

spring-cloud-starter-netflix-eureka-server這個(gè)引用會(huì)使我的啟動(dòng)容器變?yōu)閠omcat,注釋了就沒問題。
我查看該引用的pom,最終在spring-cloud-netflix-eureka-server的pom中找到了他加了spring-boot-starter-web的引用,而這個(gè)引用中又引用了spring-boot-starter-tomcat。
我猜測(cè)是這一處造成的,但是我沒有找到好的解決辦法覆蓋這個(gè)啟動(dòng),請(qǐng)問有什么辦法達(dá)到我的目的?

回答
編輯回答
莓森

沒試過netty,但換jetty是這樣:

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jetty</artifactId>
        </dependency>
2018年2月12日 01:52