SpringBoot框架搭建以及返回数据类型为json类型示例

本文介绍了SpringBoot框架的优势,如内置Tomcat、简化依赖管理,并提供了项目结构和启动配置的说明。通过一个实际的Controller示例,展示了如何设置注解以返回JSON类型的数据,帮助读者理解SpringBoot的快速启动与应用。
摘要由CSDN通过智能技术生成

SpringBoot是Pivotal团队提供的全新框架,它的存在减少了我们对代码的需求,前面我们在进行Spring项目搭建的时候导入了很多依赖,正是因为SpringBoot的产生让我们减少了很多依赖的注入。它最重要的是自带Tomcat服务器,让我们在启动项目的时候不用那么繁琐的去配置Tomcat的很多配置,我们只需要在其中写一个Controller方法,并且加上注解,便可以将Tomcat启动,以及让整个项目跑动起来,正是前人的聪明让我们如今在实际项目中达到了高效性。其实它就是一些库的集合,它能够被任意项目的构建系统所使用。
以下是我查找了别人的代码并且加上自己的理解让整个项目跑动起来,亲测有效。

这是我项目中结构:
image.png

pom.xml代码:

<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
  distributed with this work for additional information
  regarding copyright ownership.  The ASF licenses this file
  to you under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance
  with the License.  You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an
  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  KIND, either express or implied.  See the License for the
  specific language governing permissions and limitations
  under the License.
-->
<!-- $Id: pom.xml 642118 2008-03-28 08:04:16Z reinhard $ -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值