Spring(Spring Boot)-IDEA+Maven 建立Restful Web Service 基本项目

本文档介绍了如何使用IDEA、Maven、Spring和Spring Boot创建一个基本的RESTful Web Service项目。内容包括:创建Maven项目,配置pom.xml,编写GreetingController以处理HTTP请求,并利用Jackson库将对象转换为JSON格式。通过运行Application启动服务,最终可以通过http://127.0.0.1:8080/greeting?name=...进行访问。
摘要由CSDN通过智能技术生成

Restful 是一个概念,Rest是一个架构,与其唯一绑定的实例就是http。

关于restful:https://www.runoob.com/w3cnote/restful-architecture.html

内容来源于spring官网:https://spring.io/guides/gs/rest-service/

使用 Spring/SpringBoot/Maven/Tomcat

1.使用IDEA建立Maven项目

  创建完之后在src/main/java下创建包 hello

         目录结构为:

└── src
    └── main
        └── java
            └── hello

配置pom.xml

  1. <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    
    <groupId>lsl</groupId>
    <artifactId>RestfulWebServiceHelloworld</artifactId>
    <version>1.0-SNAPSHOT</version>
    
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.6.RELEASE</version>
    </parent>
    
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.jayway.jsonpath</groupId>
            <artifactId>json-path</artifactI
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值