【spring-boot接入Resteasy】

spring-boot示例


spring-boot接入Resteasy

  • spring-boot示例
  • 前言
  • 相关版本
  • 一、resteasy是什么?
  • 二、接入步骤
    • 1.创建项目(略)
    • 2.添加依赖
    • 3.添加启动类
    • 4.添加测试类
    • 5. 启动与测试
  • 总结
  • 源代码


前言

这里演示如何在spring-boot中接入resteasy框架。


相关版本

依赖 版本
spring-boot 2.7.9
resteasy-spring-boot-starter 5.0.0.Final

一、resteasy是什么?

RESTEasy是一个JBoss/Red Hat项目,它提供了各种框架来帮助您构建RESTful Web服务和RESTful Java应用程序。它是Jakarta RESTful Web Services的实现,这是一个Eclipse Foundation规范,通过HTTP协议为RESTful Web服务提供Java API。
此外,RESTEasy还实现了MicroProfile REST客户端规范API(本人英文不行,纯纯百度翻译)。

我自己的理解就是一个RESTful Web框架。

resteasy官方网站:https://resteasy.dev

二、接入步骤

1.创建项目(略)

有需要的可以去源代码查看

2.添加依赖


<dependency>
	<groupId>org.jboss.resteasygroupId>
	<artifactId>resteasy-spring-boot-starterartifactId>
	<version>5.0.0.Finalversion>
dependency>

<dependency>
	<groupId>org.springframework.bootgroupId>
	<artifactId>spring-boot-starterartifactId>
	<version>2.7.9version>
dependency>

3.添加启动类

package work.silian.resteasy;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class ResteasyApplication {

	public static void main(String[] args) {
		SpringApplication.run( ResteasyApplication.class ,args );
	}
	
}

4.添加测试类

package work.silian.resteasy.controller;

import javax.ws.rs.GET;
import javax.ws.rs.Path;

import org.springframework.stereotype.Controller;

@Path("/test")
@Controller
public class TestController {
	
	@Path("/demo")
	@GET
	public String test() {
		System.out.println("test");
		return "helloworld";
	}
	
}

5. 启动与测试

执行ResteasyApplication 类的main方法启动,访问http://127.0.0.1:8080/test/demo即可。

【spring-boot接入Resteasy】_第1张图片

总结

以上主要是对spring-boot接入resteasy的记录,防止自己遗忘没有地方查找资料。

源代码

https://gitee.com/yichanggeng/spring-boot-demo/tree/develop/spring-boot-resteasy

你可能感兴趣的:(springboot示例,spring,boot)