相信很多人开发web程序的时候用过ssm或者是ssh等一些框架,这些传统的开发方式会有大量的XML配置文件存在项目当中,整合第三方框架繁琐的配置会导致开发效率的降低。
Springboot通过前期很少的配置以及嵌入式的应用服务器可以很快速的启动你的服务,无论你用的开发工具是eclipse还是idea,spring还提供了快速搭建应用的插件
springboot相比传统的开发方式的优点:
1:简化了配置
2:简化了编码
3:简化了部署
我用的开发工具是eclipse,一直听说idea怎么怎么好用,但是由于我对于eclipse长期的感情导致我一直没有更换(就是懒啊),所以说一下通过eclipse安装springsource-tool-suite(sts插件)快速创建一个springboot应用。(idea也有插件可以直接创建springboot服务,可以查看官网资料)
eclipse安装sts插件分为在线安装和离线安装,在线太慢推荐离线安装
1)安装maven环境,参考下面这个文章:
eclipse安装maven环境 叮当LIU,公众号:PLMCODEmyEclipse或eclipse搭建Maven环境
2)下载sts离线安装包
因为我的eclipse版本是4.10.0所以下载的sts离线压缩包的版本是3.9.7,文件名称(springsource-tool-suite-3.9.7.RELEASE-e4.10.0-updatesite.zip),在官网:http://spring.io/tools/sts/all 找到eclipse对应的sts离线安装包。百度也行...
3)下载完之后在eclipse中进行安装
点击Eclipse中Help==>Install New Software...菜单,进入Available Software
等待一段时间安装完成之后在eclipse的创建项目页面总查看是否有SpringBoot选项,有则说明安装成功
4)在eclipse中创建SpringBoot项目
选择new Spring Starter Project,创建springboot项目
创建完之后如果pom.xml文件中的标签报错提示:
Project build error: Non-resolvable parent POM for com.example:demo:0.0.1-SNAPSHOT: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.2.6.RELEASE from/to mirrorId (http://central.maven.org/maven2/): central.maven.org an
解决办法:
1:先清空maven仓库中的内容
2:在maven的conf文件夹中的settings.xml文件中的mirrors标签中加入下面内容
repo2 central spring2.0 for this Mirror. https://repo.spring.io/libs-milestone net-cn central Human Readable Name for this Mirror. http://maven.net.cn/content/groups/public/ ui central Human Readable Name for this Mirror. http://uk.maven.org/maven2/ ibiblio central Human Readable Name for this Mirror. http://mirrors.ibiblio.org/pub/mirrors/maven2/ jboss-public-repository-group central JBoss Public Repository Group http://repository.jboss.org/nexus/content/groups/public
3:在项目中右键选择maven==》update project ,选中Force Update of Snap...选项,等待一段时间(需要下载相关文件)
创建完成后的demo项目如下:选择Run As==>Spring Boot App运行出现下面控制台内容表示项目搭建成功
PS:欢迎关注我的技术个人公众号:PLMCODE,记录个人学习道路上会遇到的知识点(RCP开发,SOA开发,ITK开发,AWC开发,WEB开发),希望我们可以相互学习,微信号:LyleMack。