前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >使用Idea迅速构建一个Spring Boot应用与部署

使用Idea迅速构建一个Spring Boot应用与部署

作者头像
wuweixiang
发布2018-08-14 10:23:50
6290
发布2018-08-14 10:23:50
举报
文章被收录于专栏:吴伟祥

构建

1、选择File->New->Project,在对话框中选中Spring Initializr,给项目配置合适的SDK,点击Next.

2.根据需要选择Next直至Finish

3.运行Run->Edit Configurations。在弹出的对话框中新建一个Spring Boot配置,在右侧选择Main class,并填写其它相关的信息。点击OK保存配置文件。即可通过调试按钮启动一个Spring Boot调试了。

注意:第二步中,若没有选择Web->Web,则需要在pom中加入

代码语言:javascript
复制
        <dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>

4.在启动类中加入@ComponentScan

5.创建DemoController

代码语言:javascript
复制
package com.example.controller;

import org.springframework.web.bind.annotation.*;

/**
 * DemoController
 *
 * @author weixiang.wu
 * @date 2018-07-02 17:10
 **/
@RestController
@RequestMapping("/demo")
public class DemoController {

	@RequestMapping(value = "/helloGet/{id}", method = RequestMethod.GET)
	@ResponseBody
	public String sayHello(@PathVariable("id") Long id) {
		return "hello world,i'm get method,my lucky number is " + id;
	}

	@RequestMapping(value = "/helloPost", method = RequestMethod.POST)
	@ResponseBody
	public String sayHi(@RequestParam("id") Long id) {
		return "hello world,i'm post method,my lucky number is " + id;
	}
}

6.启动后访问demo接口

7.成功结束。

部署为可运行的jar

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 构建
  • 部署为可运行的jar
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档