Eclipse引入SpringBoot
从这一博客开始学习SpringBoot,今天学习Eclipse配置SpringBoot.Eclipse导入SpringBoot有两种方式,一种是在线一个是离线方式。
一、在线安装
点击Eclipse中的help->Eclipse Marketplace,搜索sts,如下图,可一直报错下面的错误,所以又下载离线包进行的安装。
二、离线安装
开始的时候我下载的是springsource-tool-suite-3.9.4.RELEASE-e4.7.3a-updatesite这个版本。然后help->Install New Software->Add->Archive,这里由于我没解压所以选的是Archive,选择要安装的组件,点击Next.
三、使用SpringBoot创建项目
上面配置好之后可以使用SpringBoot来尝试着新建一个web项目。配置之后再New Project的页面会显示出Spring Boot选项,选择 Spring Starter Project。
配置项目名称,版本等信息。
这里选择创建web项目
创建完成之后项目的目录结构如下图
四、测试
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
package com.example.demo; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; @RestController //@Controller //@ResponseBody @RequestMapping("/sbs") public class helloController { @RequestMapping("/hello") public String Hello(){ return "Hello World"; } }
这里需要注意上图的红色框的部分,这里使用的是@RestController,其实也可以使用下面注释的两个注解。点击CuiywTestApplication.java右键Run As->Spring Boot App启动。下图是启动成功的日志。
在浏览器输入http://localhost:8080/sbs/hello,可以看到下图返回的hello world.
五、出现的错误
如果启动springboot之后再次启动时就会报错,APPLICATION FAILED TO START, Failed to start connector [Connector[HTTP/1.1-8080]]
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
*************************** APPLICATION FAILED TO START *************************** Description: The Tomcat connector configured to listen on port 8080 failed to start. The port may already be in use or the connector may be misconfigured. Action: Verify the connector's configuration, identify and stop any process that's listening on port 8080, or configure this application to listen on another port.
这里我直接通过任务管理器->用户,结束javaw:Java(TM) Platform SE binary这个任务。
相关文章
- JavaWeb-SpringBoot_使用H2数据库实现用户注册登录
- Springboot内部方法调用,aop切面失效
- SpringBoot注解把配置文件自动映射到属性和实体类实战
- [IDEA] [SpringBoot] 项目所写的内容不能同步到编译出的文件中
- springboot整合shiro
- SpringBoot中Junit测试注入Bean失败的解决方法
- Eclipse和Maven的结合使用--Please make sure the -vm option in eclipse.ini
- Atitit springboot helloword 最简化 attilax总结
- springboot 中使用事务
- Springboot怎么集成Thymeleaf模板引擎?
- Springboot怎么快速集成Redis?
- 【面试3】Springboot自动装配原理解析
- springboot+shiro:ShiroConfiguration配置
- SpringBoot中使用Shiro和JWT做认证和鉴权
- idea 创建 springboot 模块报错-解决
- 如何使用Eclipse API 提供 org.eclipse.wst.wsdl 要解决阅读WSDL档?
- Eclipse: eclipse.metadata.pluginsorg.eclipse.cdt.core
- springboot使用jxls导出excel___(万能通用模板)--- SpringBoot导入、导出Excel文件___SpringBoot整合EasyExcel模板导出Excel