首页 > 编程语言 > 详细

(017)Spring Boot之引入jetty

时间:2019-11-24 21:46:48      阅读:73      评论:0      收藏:0      [点我收藏+]

  springboot引入spring-boot-starter-web,默认会引入tomcat。

  所以引入jetty先要排除掉tomcat,然后添加jetty的依赖,如下所示:

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

  启动如下图所示:

技术分享图片

   测试类如下:

package com.edu.spring.springboot;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class AccountController {

    @RequestMapping("/hello")
    public String reg(){
        return "hello Tom";
    }
    
}

  浏览器输入:http://127.0.0.1:8080/hello 即可返回:hello Tom

 

(017)Spring Boot之引入jetty

原文:https://www.cnblogs.com/javasl/p/11918176.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!