使用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 ...
随机推荐
- DSP学习教程基于28335(一)
首先说明:开发环境Manjaro linux,内核5.0,滚动升级版本,随时都是最新,CCS也是最新的CCv 8 #include "DSP2833x_Device.h" // 这 ...
- Python 如何将字符串转为字典
在工作中遇到一个小问题,需要将一个 python 的字符串转为字典,比如字符串: user_info = '{"name" : "john", "ge ...
- 【hihocoder】sam1-基本概念
这题有毒…… 原本只是想复习下sam,于是写…… 后来发现自己傻了不知道怎么维护endpos…… 一气之下直接kmp拉倒,mdzz UPD:现在我好像会维护endpos了…… #include< ...
- UML基础
UML基础系列:类图 类图描述系统中类的静态结构,它不仅定义系统中的类,描述类之间的联系,如关联.依赖.聚合等,还包括类的内部结构(类的属性和操作).类图描述的是静态关系,在系统的整个生命周期中都 ...
- Jmeter接口测试示例
如果是Web,需要使用badboy进行录制,今天讲的是接口,因此可以不用录制. (1)新建测试计划 (2)添加http请求默认值 (3)添加http信息头管理器 (4)添加token的正则表达式:&q ...
- 利用CSS3伪类做3D按钮
这是通过css3伪类实现的3d按钮,html代码为: <div id="container_buttons"> <p><a class="a ...
- Sql Server中常用函数replicate
SQL常用函数之三 REPLICATE () 按指定次数重复字符表达式. 语法 REPLICATE ( character_expression, integer_expression) 参数 cha ...
- JavaScript如何判断变量是数组还是对象
编辑 方法一:通过判断变量的类型,并且变量的length属性(除了有一种例外是arguments对象–当给函数传参时数据存储的地方) var arr=[2,3,4]; var obj={"n ...
- CentOS7安装配置WPS
1.下载 地址:http://wps-community.org/downloads 2.安装 rpm -ivh wps-office-10.1.0.5707-1.a21.x86_64.rpm 3.运 ...
- LintCode 13. Implement strStr()
LintCode 13. Implement strStr() 题目描述 对于一个给定的 source 字符串和一个 target 字符串,你应该在 source 字符串中找出 target 字符串出 ...