首页 > 编程语言 > 详细

Spring Boot引入jetty

时间:2021-07-15 17:21:37      阅读:19      评论:0      收藏:0      [点我收藏+]

在pom.xml中引入依赖   springboot核心依赖

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

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

 1 <!--配置父项目:维护版本-->
 2     <parent>
 3         <groupId>org.springframework.boot</groupId>
 4         <artifactId>spring-boot-starter-parent</artifactId>
 5         <version>2.5.2</version>
 6     </parent>
 7 
 8     <dependencies>
 9         <!--springboot-starter-web依赖-->
10         <dependency>
11             <groupId>org.springframework.boot</groupId>
12             <artifactId>spring-boot-starter-web</artifactId>
13             <!--1.禁用tomcat-->
14             <exclusions>
15                 <exclusion>
16                     <groupId>org.springframework.boot</groupId>
17                     <artifactId>spring-boot-starter-tomcat</artifactId>
18                 </exclusion>
19             </exclusions>
20         </dependency>
21         <!--引入jetty依赖-->
22         <dependency>
23             <groupId>org.springframework.boot</groupId>
24             <artifactId>spring-boot-starter-jetty</artifactId>
25         </dependency>
26     </dependencies>

 

启动后如下:

 

 

 

技术分享图片

 

 

 

技术分享图片

控制层里:

 1 package cn.jbit.controller;
 2 
 3 import org.springframework.web.bind.annotation.RequestMapping;
 4 import org.springframework.web.bind.annotation.RestController;
 5 
 6 @RestController/*标注控制层所有的方法都是异步请求的方法(用来做测试*/
 7 public class UserController {
 8     @RequestMapping("/hello")
 9     public String hello(){
10         return "hello,Spring!!!!!";
11     }
12 }

启动类中:

 1 package cn.jbit;
 2 
 3 import org.springframework.boot.SpringApplication;
 4 import org.springframework.boot.autoconfigure.SpringBootApplication;
 5 
 6 @SpringBootApplication/*标注启动类注解*/
 7 public class SpringBoot02Application {
 8     public static void main(String[] args) {
 9         SpringApplication.run(SpringBoot02Application.class,args);
10     }
11 }

yml中 (看需求更改):

 

 

 技术分享图片

Spring Boot引入jetty

原文:https://www.cnblogs.com/Mr-Wang0428/p/15015663.html

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