准备工作

将以下代码加入idea的live template,命名为springbootStartup

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3..RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent> <properties>
<project.build.sourceEncoding>UTF-</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency> </dependencies> <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

Create New Project

                                                   

 

 

 

 

 

添加maven支持

添加pom.xml

在project的根目录上的右键菜单中选择"Add Framework Support",添加maven支持。

 

 

 

设置maven坐标

 

补全maven其他设置

在pom.xml中,坐标设置下面输入sp,IDE自动弹出前面设置的live template:“springbootStartup”,按下"tab"键盘,剩余的maven代码将会自动补全。

 

 

新建包结构

 

新建application类

 

 

 

 

 

导入:

import org.springframework.boot.SpringApplication;

在main函数中添加如下代码:

SpringApplication.run(SpringBootDemoApplication.class, args);

添加controller类

 

添加@RestController

 

添加request mapping代码

@RequestMapping("/hello")
String hello() {
return "this is a test";
}

 

测试

 

第一次启动报错,显示8080端口已经被占用

因此需要修改端口号,操作如下:
在resources目录下新建application.properties, 输入如下内容:

server.port=8081

然后重新启动程序,在浏览器中访问地址:
http://localhost:8081/hello

 

最新文章

  1. smartform
  2. ie的不同版本测试
  3. svn记录删除
  4. hdu2807 矩阵乘法+floyd
  5. 数据结构中的堆棧在C#中的实现
  6. NVDIMM典型应用及技术发展
  7. (转)Facebook内部分享:26个高效工作的小技巧
  8. 转:Java开发牛人十大必备网站
  9. 【每天一个Linux命令】19. 创建文件夹目录命令mkdir
  10. Latex 去掉行号
  11. AFNetworking提示3840 Unescaped control character around character XXX
  12. Surface RT2使用情况
  13. 87、代码适配IphoneX
  14. PAT (Basic Level) Practise - 换个格式输出整数
  15. C# WinForm文章收集
  16. js高级-数组的map foreach 方法
  17. 讲讲我当年是怎么拿到AI研发公司offer的
  18. Zookeeper学习记录(二):使用以及配置
  19. Ubuntu Server 13.10 安装配置图解教程
  20. Linux局域网内文件传送

热门文章

  1. Linux从入门到放弃
  2. tenda t402 家庭版 有线路由器
  3. webIcon
  4. XML 约束 (DTD和 schema)
  5. http通信过程中,Web浏览器与Web服务器之间将完成下列7个步骤
  6. [PAT] 1144 The Missing Number(20 分)
  7. ES6 一种新的数据结构--Map跟Objct的区别
  8. 182. Duplicate Emails
  9. coercing to Unicode错误的一个解决办法
  10. Java中多线程问题