3

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]
treeliked
  • 383
  • 1
  • 4
  • 15

2 Answers2

3

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;
}
treeliked
  • 383
  • 1
  • 4
  • 15
  • Programmatic declaration was used in earlier versions of spring boot. If you are using Spring boot 2.x you should ideally only exclude it from your dependency list and it should function. However, I am running into the issue of it not functioning without having it programmatically defined. – SteeleDev Feb 06 '19 at 21:30
0
@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>
kumar
  • 497
  • 4
  • 12