准备工作

将以下代码加入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

 

使用idea搭建Spring boot开发初始环境的更多相关文章

  1. 快速搭建Spring Boot + Apache Shiro 环境

    个人博客网:https://wushaopei.github.io/    (你想要这里多有) 一.Apache Shiro 介绍及概念 概念:Apache Shiro是一个强大且易用的Java安全框 ...

  2. Spring Boot实战一:搭建Spring Boot开发环境

    一开始接触Spring Boot就感到它非常强大,也非常简单实用,遂想将其记录下来. 搭建Spring Boot工程非常简单,到:http://start.spring.io/ 下载Spring Bo ...

  3. spring boot 开发环境搭建(Eclipse)

    Spring Boot 集成教程 Spring Boot 介绍 Spring Boot 开发环境搭建(Eclipse) Spring Boot Hello World (restful接口)例子 sp ...

  4. Spring Boot入门系列(十五)Spring Boot 开发环境热部署

    在实际的项目开发过中,当我们修改了某个java类文件时,需要手动重新编译.然后重新启动程序的,整个过程比较麻烦,特别是项目启动慢的时候,更是影响开发效率.其实Spring Boot的项目碰到这种情况, ...

  5. Spring Boot 开发系列一 开发环境的一些九九

    从今天开始写这个Spring Boot 开发系列,我是第二周学习JAVA的,公司号称springboot把JAVA的开发提升到填空的能力,本人是NET转JAVA的,想看看这个填空的东西到底有多强.废话 ...

  6. 使用IDEA搭建Spring Boot入门项目

    简介 Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程.该框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化的配置 ...

  7. idea搭建Spring Boot+Mybatis及使用教程

    环境准备 idea 15 jDK tomcat maven 搭建方式 官网下载源码包解压缩 使用idea中的Spring initializr创建 这两种方法创建的项目完全相同,只是操作方式不一样 这 ...

  8. Myeclipse下使用Maven搭建spring boot项目

    开发环境:Myeclipse2017.JDK1.6.Tomcat 8.0.Myeclipse下使用Maven搭建spring boot项目,详细过程如下: 1. New -> Project.. ...

  9. Myeclipse下使用Maven搭建spring boot项目(第二篇)

    现在需要搭建spring boot框架,并实现一个HelloWorld的项目,让程序真正运行起来. 一.在pom.xml中引入spring-boot-start-parent,spring官方的叫st ...

随机推荐

  1. foreign key constraint fails错误的原因

    建表:CREATE TABLE Course ( Cno Char(4) PRIMARY KEY, Cname Char(40), Cpno Char(4), Ccredit Int, FOREIGN ...

  2. pam会话函数详解

    pam会话函数详解 http://www.xuebuyuan.com/2223069.html http://blog.itpub.net/15480802/viewspace-1406088/ ht ...

  3. 2016多校第4场 HDU 6076 Security Check DP,思维

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6076 题意:现要检查两条队伍,有两种方式,一种是从两条队伍中任选一条检查一个人,第二种是在每条队伍中同 ...

  4. 2015多校第7场 HDU 5379 Mahjong tree 构造,DFS

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5379 题意:一颗n个节点n-1条边的树,现在要给每个节点标号(1~n),要求:(1)每一层的兄弟节点的 ...

  5. vscode和phpStorm使用xdebug调试设置

    phpStorm http://www.cnblogs.com/cxscode/p/7045944.html http://www.cnblogs.com/cxscode/p/7050781.html ...

  6. supervisor error: <class 'socket.error'>, [Errno 110]

    supervisorctr status报错 error: <class 'socket.error'>, [Errno 110] Connection timed out: file: ...

  7. 关于Free的override不能省略的问题,切记,虚方法是可以被覆盖的方法。

     

  8. 小程序 image跟view标签上下会有空隙

    解决方案 就是可以在image那里设置vertical-align:top/bottom/text-top/text-bottom 原因:图片文字等inline元素默许是跟父级元素的baseline对 ...

  9. python 函数内置方法short_desc

    1. 给函数设置一个文本 def action_checked(self, request): pass action_checked.short_desc = "签到" # sh ...

  10. Idea创建模板

    新建文件模板 /** * * @author zenglw * @date ${DATE} */ Mapper #if (${PACKAGE_NAME} && ${PACKAGE_NA ...