使用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 ...
随机推荐
- Python标准库笔记(1) — string模块
String模块包含大量实用常量和类,以及一些过时的遗留功能,并还可用作字符串操作. 1. 常用方法 常用方法 描述 str.capitalize() 把字符串的首字母大写 str.center(wi ...
- sunos kernel src leakrs
https://github.com/joede/libezV24 https://github.com/ysei/siriusSparcV8 https://github.com/omniti-la ...
- 超级rtmp服务器和屌丝wowza
超级rtmp服务器和屌丝wowza http://blog.csdn.net/win_lin/article/details/11927973
- sicily 1020. Big Integer
Description Long long ago, there was a super computer that could deal with VeryLongIntegers(no VeryL ...
- .NET Core、.NET Standard、Xamarin和.NET Framework对比
近日,微软发布了.NET Core 2.0,但是开发人员中间仍然存在一些疑惑,就是.NET Core..NET Standard.Xamarin和.NET Framework有什么不同. .NET F ...
- 常用模块二(hashlib、configparser、logging)
阅读目录 常用模块二 hashlib模块 configparse模块 logging模块 常用模块二 返回顶部 hashlib模块 Python的hashlib提供了常见的摘要算法,如MD5,SH ...
- hdu 3667(最小费用最大流+拆边)
Transportation Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
- 玩转RaspberryPi
step1:烧制树莓派内存卡 可以用[Linux系统烧制]http://www.williamsang.com/archives/1764.html 如果用windows烧制的话,就用Win32 Di ...
- PHP通过mysqli连接mysql数据库
数据库连接的天龙八步: 1.连接数据库 连接:mysqli_connect 2.成功与否判断 连接错误号:mysqli_connect_errno 连接错误信息:mysqli_connect_erro ...
- java中常用的String方法
1 length()字符串的长度 String a = "Hello Word!"; System.out.println(a.length); 输出的结果是字符串长度10. 2 ...