treeliked
treeliked

Reputation: 383

In springboot, i can't exclude embedded tomcat

I have exclude the embedded dependency, but it always starts with tomcat instead of undertow. I have been crazy on this question. Hope someone could help me, thanks very much. I have tried many methods , but they didn't work. Does it the reason of IDEA? Any answer is helpful.

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jdbc</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-to-slf4j</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>com.alibaba</groupId>
        <artifactId>druid-spring-boot-starter</artifactId>
        <version>1.1.10</version>
    </dependency>

    <dependency>
        <groupId>org.mybatis.spring.boot</groupId>
        <artifactId>mybatis-spring-boot-starter</artifactId>
        <version>1.3.2</version>
    </dependency>

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

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <!--使用undertow服务器-->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-undertow</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-log4j2</artifactId>
    </dependency>

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



    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>
... 

Following the start log.

2018-08-03 14:18:12.200  INFO 9268 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 443 (https)
2018-08-03 14:18:12.225  INFO 9268 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]

Upvotes: 3

Views: 3151

Answers (2)

treeliked
treeliked

Reputation: 383

Thanks all. I added the following code. And it works.

    @Bean
    public  UndertowServletWebServerFactory
 undertowServletWebServerFactory() {
    UndertowServletWebServerFactory factory = new 
    UndertowServletWebServerFactory();
    factory.addBuilderCustomizers(builder -> 
builder.setServerOption(UndertowOptions.ENABLE_HTTP2, true)                 .setServerOption(UndertowOptions.HTTP2_SETTINGS_ENABLE_PUSH,true));
    return factory;
}

Upvotes: 3

kumar
kumar

Reputation: 497

@LqS2... try this one in pom

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <exclusion>
                <artifactId>tomcat-embed-el</artifactId>
                <groupId>org.apache.tomcat.embed</groupId>
            </exclusion>
            <exclusion>
                <artifactId>tomcat-embed-core</artifactId>
                <groupId>org.apache.tomcat.embed</groupId>
            </exclusion>
            <exclusion>
                <artifactId>tomcat-embed-websocket</artifactId>
                <groupId>org.apache.tomcat.embed</groupId>
            </exclusion>
        </exclusions>
    </dependency>

Upvotes: 0

Related Questions