从零开始学springboot笔记(一)-Spring boot之Hello Word
工具:Eclipse、jdk1.8、maven;
一:先建一个maven的项目
然后再pom文件中添加相关依赖和配置,具体如下: <!-- spring boot 父节点依赖,引入这个之后相关的引入就不需要添加version配置,spring boot会自动选择最合适的版本进行添加。--><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>1.4.1.RELEASE</version></parent><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><java.version>1.8</java.version></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency></dependencies> 注意添加依赖后,记得update;
然后创建HelloController,code如下: import java.util.Date;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;@RestController public class HelloController {@RequestMapping("/hello")public String hello(){return"hello";} }
然后编码springboot启动类App.java
@SpringBootApplication public class App// extends WebMvcConfigurerAdapter {public static void main( String[]args ){System.out.println("--------------开始启动---------------!" ); SpringApplication.run(App.class, args); System.out.println( "--------------启动成功---------------!" );} }
打开app.java,右键run as java application启动springboot应用;
--------------开始启动---------------!. ____ _ __ _ _/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \\\/ ___)| |_)| | | | | || (_| | ) ) ) )' |____| .__|_| |_|_| |_\__,| / / / /=========|_|==============|___/=/_/_/_/:: Spring Boot :: (v1.4.1.RELEASE)2019-05-27 15:27:52.942 INFO 2020 --- [main] com.feiyun.springboot_hello.App : Starting App on TEST-PC with PID 2020(E:\Eclise\MyWorkPlace\springboot-hello\target\classes started by Administrator in E:\Eclise\MyWorkPlace\springboot-hello)2019-05-27 15:27:52.944 INFO 2020 --- [main] com.feiyun.springboot_hello.App : No active profile set,falling back to default profiles: default2019-05-27 15:27:52.985 INFO 2020 --- [main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4b0b0854: startup date [Mon May 27 15:27:52 CST 2019];root of context hierarchy 2019-05-27 15:27:54.084 INFO 2020 --- [main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080(http)2019-05-27 15:27:54.097 INFO 2020 --- [main]o.apache.catalina.core.StandardService : Starting service Tomcat2019-05-27 15:27:54.099 INFO 2020 --- [main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.5 2019-05-27 15:27:54.180 INFO 2020 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]: Initializing Spring embedded WebApplicationContext2019-05-27 15:27:54.180 INFO 2020 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1198ms2019-05-27 15:27:54.327 INFO 2020 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/] 2019-05-27 15:27:54.331 INFO 2020 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*] 2019-05-27 15:27:54.331 INFO 2020 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*] 2019-05-27 15:27:54.331 INFO 2020 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*] 2019-05-27 15:27:54.332 INFO 2020 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*] 2019-05-27 15:27:54.592 INFO 2020 --- [main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4b0b0854: startup date [Mon May 27 15:27:52 CST 2019];root of context hierarchy 2019-05-27 15:27:54.647 INFO 2020 --- [main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/hello]}"onto public java.lang.String com.feiyun.springboot_hello.HelloController.hello()2019-05-27 15:27:54.648 INFO 2020 --- [main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/getDemo]}"onto public com.feiyun.springboot_hello.Demo com.feiyun.springboot_hello.HelloController.getDemo()2019-05-27 15:27:54.652 INFO 2020 --- [main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String,java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)2019-05-27 15:27:54.652 INFO 2020 --- [main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)2019-05-27 15:27:54.674 INFO 2020 --- [main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 2019-05-27 15:27:54.674 INFO 2020 --- [main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 2019-05-27 15:27:54.706 INFO 2020 --- [main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 2019-05-27 15:27:54.825 INFO 2020 --- [main]o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup2019-05-27 15:27:54.870 INFO 2020 --- [main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080(http)2019-05-27 15:27:54.873 INFO 2020 --- [main] com.feiyun.springboot_hello.App : Started App in 2.258 seconds (JVM running for 2.533) --------------启动成功---------------!
运行成功后,打开浏览器访问hello方法,注意默认端口是8080;
end;
hello
转载于:https://www.cnblogs.com/xh_Blog/p/10931105.html
从零开始学springboot笔记(一)-Spring boot之Hello Word相关推荐
- 从零开始学springboot笔记(二)-Spring boot返回json数据(中文无乱码)
先创建json实体类,如下: public class Demo {private int age; private String address; private String name; priv ...
- SpringBoot开发之Spring Boot入门
SpringBoot开发之SpringBoot入门 一.Spring Boot概述 1.什么是Spring Boot 2.Spring Boot的优点 二.第一个Spring Boot应用 1.创建S ...
- 读书笔记《Spring Boot+Vue全栈开发实战》(下)
本书将带你全面了解Spring Boot基础与实践,带领读者一步步进入 Spring Boot 的世界. 前言 第九章 Spring Boot缓存 第十章 Spring Boot安全管理 第十一章 S ...
- springboot socket服务端_从零开始学SpringBoot之Spring Boot WebSocket:编码分析
前言: 在上一篇文章中讲到了WebSocket的原理,这节中我们先简单的编码分析下,这样有助于在之后的实战编码. 说明: (1)编码中使用的Spring Boot版本是:1.5.8: (2) 使用We ...
- SpringBoot学习笔记(2) Spring Boot的一些配置
外部配置 Spring Boot允许使用properties文件.yaml文件或者命令行参数作为外部配置 使用@Value注解,可以直接将属性值注入到你的beans中,并通过Spring的Enviro ...
- 为什么你学了 N 遍 Spring Boot,至今还是学生项目?你的问题在这里 | 原力计划...
作者 | bugpool 出品 | CSDN博客 为什么你学了n遍<1天精通Spring Boot>,至今还是不精通Spring Boot,甚至还是停留在学生项目?真正要做项目就应该一步到 ...
- (附源码)springboot+mysql+基于Spring boot开发电子宿舍管理系统 毕业设计132056
摘 要 科技进步的飞速发展引起人们日常生活的巨大变化,电子信息技术的飞速发展使得电子信息技术的各个领域的应用水平得到普及和应用.信息时代的到来已成为不可阻挡的时尚潮流,人类发展的历史正进入一个新时代. ...
- springboot+mysql+基于Spring boot开发电子宿舍管理系统 毕业设计-附源码132056
摘 要 科技进步的飞速发展引起人们日常生活的巨大变化,电子信息技术的飞速发展使得电子信息技术的各个领域的应用水平得到普及和应用.信息时代的到来已成为不可阻挡的时尚潮流,人类发展的历史正进入一个新时代 ...
- 【笔记】Spring Boot
尚硅谷-SpringBoot2核心技术与响应式编程 文章目录 一.Spring与SpringBoot 1.Spring能做什么 2.Spring的生态 3.Spring5重大升级 1.响应式编程 2. ...
- SpringBoot (八) :Spring Boot多数据源(JdbcTemplate)配置与使用
什么是JdbcTemplate 为了使 JDBC 更加易于使用,Spring 在 JDBCAPI 上定义了一个抽象层, 以此建立一个JDBC存取框架. 作为 SpringJDBC 框架的核心, JDB ...
最新文章
- html 表格点击修改全部替换成文本_excel表格计算一个数据在总值中的占比
- 机器学习笔记 时间序列预测(基本数据处理,Box-Cox)
- 成功解决Exception “unhandled AttributeError“ module ‘cv2.cv2‘ has no attribute ‘estimateRigidTransform‘
- 75.Android之基本架构
- 一文看懂高可用:异地多活
- Windows消息机制VC
- python中else和if的结合语句_python中else和if的结合语句_python中的if-else语句和字典...
- C 语言结构体成员赋值的深拷贝和浅拷贝
- VB 打开文件夹,并选中指定的文件
- 关于Cocos2d-x发布游戏的时候遇到的问题和解决
- Python 三目运算符(三分支)
- Nginx+php+fastcgi的原理与关系
- 【Python实现杨辉三角】
- 从0搭建一个邮件服务器(用于邮件推送以及邮件群发业务)
- 学校固定资产管理系统由谁来做,云呐RFID固定资产管理系统
- 不同斜率的直线段中点Bresenham误差项计算公式
- 猜数游戏(人机交互)
- Annotated Potholes Image Dataset下载
- R count函数_[R learning]-0018-R语言绘图基础, 画了一天,不妨进来看看~
- 自动对焦模块理论基础及其硬件实现浅析(一)
热门文章
- 【笔记】Android APP 上架 Google Play 采坑记之「应用签名证书」
- 微信开放平台修改微信分享的小图标后,移动端显示的分享的小图标未改变的问题解决
- 二项式定理与多变量函数的泰勒展开_拔剑-浆糊的传说_新浪博客
- idea2018下载-补丁破解激活
- mysqld --initialize 错误:mysqld: Can‘t create/write to file ‘G: ool\mysql\data\is_writable‘
- 当AI有了“自由意志”
- 深度学习去燥学习编码_有关自己学习编码的最困难的事情以及如何解决它们
- 零基础学DevOps必看教程,带你10分钟快速实战入门DevOps
- php四六级报名考试源码,全国大学英语四六级考试报名官网
- php 防恶意注册,论坛防恶意注册 for PHPWindv5.0.1