springboot入门(一)--快速搭建一个springboot框架

原文出处

 

前言
在开始之前先简单介绍一下springboot,springboot作为一个微框架,它本身并不提供Spring框架的核心特性以及扩展功能,只是用于快速、敏捷地开发新一代基于Spring框架的应用程序,总的来说springboot不是为了要替代Spring IO平台上众多的项目也不是spring的升级,它只是提供一种不同的开发体验,一种几乎没有配置文件的快速开发的框架,让你体验一下java做到接近ruby on rails开发速度的感觉。

正文
说了一堆废话直接进入正文,接下来将体验到没有了繁琐的配置文件之后使用springboot开发一个网站有多快,Spring IO上提供了一个功能快速创建springboot初始化项目:http://start.spring.io/ 进入网页之后填好Group和Artifact,由于我们要创建的是web项目,所以在Search for dependencies中填入Web后点Generate Project生成项目,如果还需要添加其他的依赖如mybatis可以继续添加或点开Switch to the full version 寻找

 

 

至此一个初始化项目就生成了,将该项目导入intelliJ IDEA中,项目结构如图:

 

点开DemoApplication,这是一个带main方法的普通的java类,也是springboot的启动类,在类上加上@RestController注解,然后写一个index方法返回hello word!字符串到浏览器.

@RestController 是一种特殊的@Controller 该注解表示该Controller返回的都是json格式的数据并且在@RestController 中包含了@ResponseBody 注解,所以可以不用再在方法上@ResponseBody


至此一个简单的web项目搭建完成,启动main方法,再浏览器输入:localhost:8080/hello 就能看到结果了,是不是感觉很简单! springboot也可以配置一些东西,默认springboot会读取classpath下的application.properties文件和application.yml文件,在这些文件中可以配置端口之类的东西,包括数据源、mybatis等,springboot通过集中配置和约定优于配置的方式实现很快速的开发,关于springboot的一些配置以及注解将在下一篇中讲解。

转载于:https://www.cnblogs.com/panchanggui/p/10383709.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/278329.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

q-dir 打不开文件_Q-Dir –多窗格文件管理器

q-dir 打不开文件Sometimes when looking through a file manager, it would be nice to have more than a dual-pane view. Now you can manage your files with up to four viewing panes at once with Q-Dir. 有时,在查看文件管理器时,拥有多个双窗格…

用面向对象的方法写敲门砖

一道名为"敲门砖"的面试题: 用面向对象的方法写,点击列表内,子元素的子标签, 来删除子元素 敲门砖考点: 递归(删除标签, 需要找到列表的直属子标签, 需要通过递归层层往上找, parentNode)冒泡(只需为顶级父元素addEventListener绑定事件, 并通过e.target区分子标签, …

windows10加载动画_如何关闭动画并使Windows 10看起来更快

windows10加载动画Windows 10 fades and window animations are pure eye candy, but waiting for them to load can make your PC seem a bit slow. If you’d like an instant response, you can disable Windows 10’s animations for a snappier desktop experience. Windo…

JData大数据竞赛18年赛题-如期而至-用户购买时间预测

年前做的,也是学习别人的作品作为记录 一、赛题 表1:sku基本信息表(jdata_sku_basic_info) 表2:用户基本信息表(jdata_user_basic_info) 表3:用户行为表(jdata_user_acti…

LNMP架构(二)

2019独角兽企业重金招聘Python工程师标准>>> 一 Nginx安装 1、切换目录 # cd /usr/local/src 2、下载 # wget http://nginx.org/download/nginx-1.12.1.tar.gz 3、解压 # tar xzvf nginx-1.12.1.tar.gz 4、切换到nginx目录下 # cd nginx-1.12.1/ 5、编译 # ./confi…

edge无法上网dns_如何在Microsoft Edge中通过HTTPS启用DNS

edge无法上网dnsMicrosoft will one day enable DNS over HTTPS (DoH) for all Windows applications, but you can enable it in the new version of Microsoft Edge today with a hidden flag. DoH will improve your security and privacy online, but it isn’t yet enable…

UIButton小结

前言 本来没有打算写这篇文章的, 主要是因为在工作中遇到一些同事再用 有UIButton的时候, 有些很基本的,系统API提供的都不知道, 例如 如何让UIButton的文字居上,居左, 居右, 居下对其等一些基本点, 为此我特地写了一下UIButton小结 UIButton回顾 继承关系 NSObject -> UIRe…

Channel Allocation HDU1373

染色问题&#xff1a;相邻不能染同一种颜色 最少需要的颜色的数量最大团点的数量 #include<bits/stdc.h> using namespace std;#define N 27int n; int mp[N][N]; int ans; int alt[N][N]; int Max[N];bool dfs(int cur,int tot)//cur是s1集合的个数 {if(0cur){if(tot>…

satis原理浅析

什么是satis 我们一般是从packagist获取composer包的&#xff0c;但这些都是公开的。那如果我们想创建自己的私有库呢&#xff0c;比如企业就会有这方便的需要&#xff0c;那我们就可以用satis来创建自己的私有库。 Satis 是一个静态的 composer 资源库生成器。它像是一个超轻量…

HDU - 5686-Problem B (递推+高精)

度熊面前有一个全是由1构成的字符串&#xff0c;被称为全1序列。你可以合并任意相邻的两个1&#xff0c;从而形成一个新的序列。对于给定的一个全1序列&#xff0c;请计算根据以上方法&#xff0c;可以构成多少种不同的序列。 Input 这里包括多组测试数据&#xff0c;每组测试数…

c#写字板实现加粗功能_Windows 7中写字板和绘画中的新功能

c#写字板实现加粗功能WordPad and Paint are often overlooked accessories included in all versions of Windows since 95. They are still included in Windows 7 and now have a new look with some enhanced features. Here we will take a look at some of the new impro…

浏览器加载静态资源文件异常解决办法

2019独角兽企业重金招聘Python工程师标准>>> 1 使用chrome浏览器加载静态资源文件(css、js等)异常导致cssh和js文件不生效&#xff0c;具体报错如下: Resource interpreted as Stylesheet but transferred with MIME type text/html 原因应该是网页文档类型不一致导…

POJChallengeRound2 Guideposts 【单位根反演】【快速幂】

题目分析&#xff1a; 这题的目标是求$$ \sum_{i \in [0,n),k \mid i} \binom{n}{i}G^i $$ 这个形式很像单位根反演。 单位根反演一般用于求&#xff1a;$ \sum_{i \in [0,n),k \mid i} \binom{n}{i}f(x)^i $ 推理过程略&#xff0c;实际上也就是交换求和符号的事情。 接着就变…

用Emesene替换Windows Live Messenger

Tired of Windows Live Messenger bloat and wishing that there was a simpler and cleaner replacement that would let you use your live.com and hotmail.com accounts? Look no further, now you can have all that messenger goodness with Emesene! 厌倦了Windows Liv…

python爬虫笔记(七):实战(三)股票数据定向爬虫

目标分析及描述 #CrawBaiduStocksA.py import requests from bs4 import BeautifulSoup import traceback import redef getHTMLText(url):try:r requests.get(url)r.raise_for_status()r.encoding r.apparent_encodingreturn r.textexcept:return ""def getStockL…

myeclipse和maven的clean和build

转&#xff1a; 详解myeclipse和maven的clean和build 2018年04月20日 11:33:34 群星坠 阅读数&#xff1a;3529 版权声明&#xff1a;本文为博主原创文章&#xff0c;未经博主允许不得转载。 https://blog.csdn.net/qq_35603331/article/details/80002723MyEclipse是一个被广为…

三星Galaxy S20:如何开启黑暗模式

Justin Duino贾斯汀杜伊诺(Justin Duino)Samsung was one of the first Android manufacturers to add Dark Mode to its handsets. If you recently purchased a Galaxy S20, S20, or S20 Ultra, enabling the UI feature and setting it up on a schedule is extremely easy.…

nginx和apache限制IP地址访问的设置方法

一、nginx禁止IP地址访问1、在nginx配置文件中加入这个&#xff1a;2、重启nginx服务二、apache禁止IP地址访问1、更改vhosts.conf文件&#xff1a;NameVirtualHost 192.168.1.191 <VirtualHost 192.168.1.191:99>#DocumentRoot "/usr/local/kk-mail/data/www"…

wordweb在线编辑_使用WordWeb享受按需词典和词库功能

wordweb在线编辑Run across an unusual word or need a synonym for a word quickly? Usually that means opening a browser and doing the appropriate search. Now you can have all that word power goodness at your fingertips with WordWeb. 遇到一个不寻常的词还是需…

转://RMAN跨平台可传输表空间和数据库

参考链接&#xff1a; http://blog.itpub.net/23135684/viewspace-776048/ http://blog.sina.com.cn/s/blog_69e7b8d7010164xh.html https://www.2cto.com/database/201311/260446.html 这篇文章翻译自Oracle 11gR2官方文档。详细讨论了使用RMAN工具的CONVERT DATAFILE&#xf…