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>

  启动如下图所示:

(017)Spring Boot之引入jetty

   测试类如下:

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

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-13
  • 2021-05-28
  • 2021-06-08
  • 2021-08-25
  • 2021-08-14
  • 2021-08-13
猜你喜欢
  • 2021-12-30
  • 2021-12-15
  • 2021-06-13
  • 2021-11-12
  • 2021-10-17
  • 2022-12-23
相关资源
相似解决方案