使用idea搭建Spring boot开发初始环境
准备工作
将以下代码加入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开发初始环境的更多相关文章
- 快速搭建Spring Boot + Apache Shiro 环境
个人博客网:https://wushaopei.github.io/ (你想要这里多有) 一.Apache Shiro 介绍及概念 概念:Apache Shiro是一个强大且易用的Java安全框 ...
- Spring Boot实战一:搭建Spring Boot开发环境
一开始接触Spring Boot就感到它非常强大,也非常简单实用,遂想将其记录下来. 搭建Spring Boot工程非常简单,到:http://start.spring.io/ 下载Spring Bo ...
- spring boot 开发环境搭建(Eclipse)
Spring Boot 集成教程 Spring Boot 介绍 Spring Boot 开发环境搭建(Eclipse) Spring Boot Hello World (restful接口)例子 sp ...
- Spring Boot入门系列(十五)Spring Boot 开发环境热部署
在实际的项目开发过中,当我们修改了某个java类文件时,需要手动重新编译.然后重新启动程序的,整个过程比较麻烦,特别是项目启动慢的时候,更是影响开发效率.其实Spring Boot的项目碰到这种情况, ...
- Spring Boot 开发系列一 开发环境的一些九九
从今天开始写这个Spring Boot 开发系列,我是第二周学习JAVA的,公司号称springboot把JAVA的开发提升到填空的能力,本人是NET转JAVA的,想看看这个填空的东西到底有多强.废话 ...
- 使用IDEA搭建Spring Boot入门项目
简介 Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程.该框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化的配置 ...
- idea搭建Spring Boot+Mybatis及使用教程
环境准备 idea 15 jDK tomcat maven 搭建方式 官网下载源码包解压缩 使用idea中的Spring initializr创建 这两种方法创建的项目完全相同,只是操作方式不一样 这 ...
- Myeclipse下使用Maven搭建spring boot项目
开发环境:Myeclipse2017.JDK1.6.Tomcat 8.0.Myeclipse下使用Maven搭建spring boot项目,详细过程如下: 1. New -> Project.. ...
- Myeclipse下使用Maven搭建spring boot项目(第二篇)
现在需要搭建spring boot框架,并实现一个HelloWorld的项目,让程序真正运行起来. 一.在pom.xml中引入spring-boot-start-parent,spring官方的叫st ...
随机推荐
- 单从软件层面来说,Maya 和 Blender 差别在哪?
单从软件层面来说,Maya 和 Blender 差别在哪? https://www.zhihu.com/question/21975571
- 【LabVIEW技巧】LabVIEW中的错误2
前言 通过上一个文章的介绍,我们发现LabVIEW自带的错误管理依旧比较基础,如果需要对错误进行很好的管理,则需要进一步的进行程序编写. 用于在程序设计的过程中,为了保证程序的健壮性,我们需要 1.忽 ...
- 解决Myeclipse编译不生成.class文件问题
1.Project --> clean... 如果该操作无效,请执行2. 2.Preferences -->Java -->Compliler -->Building --& ...
- LeetCode解题报告—— Maximal Rectangle
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and ...
- redis之(十二)redis数据的持久化
[一]redis的数据为什么要持久化 --->redis的存取数据性能高,是由于将所有数据都存储在内存中.当redis重启的时候,存储在内存中的数据就容易丢失. --->把redis作为数 ...
- Centos7安装和配置Jira7.3.6
(1)安装jdk 1.下载jdk 链接:https://pan.baidu.com/s/1umdV-Cmm1wi1RP5clIJXmg 密码:zevc 2.安装jdk rpm -ivh jdk-8u1 ...
- (2)ansible主机清单文件inventory
1)inventory作用 作用:通常用于定义要管理主机的认证信息,例如ssh登录用户名,密码等相关信息 缺省文件:/etc/ansible/hosts 2)定义主机组方式 #vim /etc/ans ...
- mp4文件DASH切片程序
mp4文件DASH切片程序 一.简介 按照DASH标准文档要求与现有的DASH切片(生成DASH切片参见mb4box命令简介)来生成Initialization Segment与Media Segme ...
- Chrome浏览器你可以选择知道的知识
Chrome浏览器我想是每一个前端er必用工具之一吧,一部分原因是它速度快,体积不大,支持的新特性也比其它浏览器多,还有一部分我想就是因为它的控制台功能强大了吧,说它是神器一点也不过分,很方便.但其实 ...
- 一个通用的php正则表达式匹配或检测或提取特定字符类
在php开发时,日常不可或缺地会用到正则表达式,可每次都要重新写,有时忘记了某一函数还要翻查手册,所以,抽空写了一个关于日常所用到的正则表达式区配类,便于随便移置调用.(^_^有点偷懒). /*/ ...