eclipse下创建一个spring boot项目
一、安装STS插件
要在eclipse使用spring boot创建项目,必须先安装STS(Spring Tool Suite (STS) for Eclipse),如果网速给力的话可以选择在线安装,否则建议选择离线安装。
1.离线安装
第一个问题:准确的找到eclipse版本对应的STS插件,例如:
eclipse-Mars.4.5.2–>springsource-tool-suite-3.7.3RELEASE-e4.5.2-updatesite.zip
eclipse-neno.4.6–>springsource-tool-suite-3.7.3RELEASE-e4.6-updatesite.zip
到官网https://spring.io/tools/sts/all 找到你本机Eclipse版本对应的STS版本,并下载压缩包,或者选择。
查看自己的eclipse版本
1. 找到Eclipse的解压目录就是你的Eclipse.exe 所在的目录
2. 找到 .eclipseproduct 文件双击打开 如图:
在eclipse安装SpringSource Tool Suite(sts-eclipse)插件包括在线安装和离线安装。
打开网页:http://spring.io/tools/sts/all
可以看到:
在eclipse上 离线安装 SpringSource Tool Suite for eclipse插件:
运行eclipse--Help--Install New Software...
点击Add
随便输入插件名称: 如sts-eclipse或sts, 选择SpringSource Tool Suite的zip包(可不解压)
选择与IDE相关的项, 并去掉Contact all update…前面的勾选, 然后下一步
直接下一步
直接下一步
接受协议, 点击Finish
等待安装完成
提示:you are installing software that contains content the authenticty or validity of this software cannot be established do you want to continue with the installation(您正在安装包含内容的软件,该软件的真实性或有效性无法建立,您是否想继续安装。) 点击继续。
已安装完成, 点击YES立即重启eclipse使sts-eclipse插件生效
重启eclipse后可以看到可以创建spring项目了
至此, 完成eclipse4.6.2下离线安装SpringSource Tool Suite(sts-eclipse)插件。
2.在线安装
在eclipse上 在线安装 SpringSource Tool Suite for eclipse插件:
运行eclipse--Help--Install New Software...
剩余步骤同离线安装。
二.创建Spring Boot项目
(1)创建项目,file-->New-->other-->Spring Boot -->选择Spring starter Project。填写跟项目相关的各种信息,然后Next:
选择需要的Dependency,然后Next:
最后"Finish",就开始下载jar包了,这个过程需要的时间比较长。加载完成后 如图:
三、介绍
web开发是开发中至关重要的一部分,Web开发的核心内容主要包括内嵌Servlet和Spring MVC开发。Spring Boot提供了大量页面模版引擎,包括FreeMarker、Groovy、Thymeleaf、Velocity和Mustache,Spring Boot中 推荐使用Thymeleaf作为页面模版引擎,因为Thymeleaf提供了完美的Spring MVC的支持。
四、实战
1. 修改pom.xml文件 替换 <dependencies/>依赖项
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>1.3.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot