spring boot (五) tomcat+jetty

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zhenghuasheng/article/details/53168510

spring boot 默认使用内置tomcat来启动服务,

默认启动端口是8080

可配置参数有如下:

#内嵌tomcat配置
server.port=8089
#server.context-path= //如果没有值就不配置,可以使用默认,但不要在这里留空,会有错误
server.tomcat.uri-encoding=UTF-8

#http encoding
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
spring.http.encoding.force=true

具体可见springboot官方参数列表
http://docs.spring.io/spring-boot/docs/1.4.2.RELEASE/reference/htmlsingle/#howto-use-jetty-instead-of-tomcat

tomcat启动

jetty启动

配置依旧生效,只需将jar的依赖调整

加入jetty的starter

        <!--jetty-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jetty</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>

jetty启动

项目源码:https://github.com/zhenghuasheng/springboot-sample

猜你喜欢

转载自blog.csdn.net/zhenghuasheng/article/details/53168510
今日推荐