SpringBoot学习(一)搭建SpringBoot

今天学习一下SpringBoot的搭建。

1、官网地址

Spring | HomeLevel up your Java code and explore what Spring can do for you.https://spring.io/

第一步在start.spring.io上常见一个web项目,在依赖项搜索web,然后点击generate按钮,下载一个zip包,下载下来解压。(我就是个翻译,没啥技术难度。)

 

 第二步,它让开始码代码

java让人头疼的就是没有IDE基本干不了活,就那引入的东西,不是一般的恶心,关键你还不知道它具体在哪,通过IDE的提醒能好一点,但是在maven没有就绪以前,是没有提示的,这是我不太喜欢这个玩意的一个地方。

package com.lyw.learn;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
@RestController
public class LearnApplication {

	public static void main(String[] args) {
		SpringApplication.run(LearnApplication.class, args);
	}

	@GetMapping("/hello")
	public String hello(@RequestParam(value = "name", defaultValue = "World") String name){
		return String.format("Hello %s", name);
	}

}

代码本身比较简单,但是需要的东西可不少。

然后就运行,IDE和cmd都可以的

mvnm spring-boot:run

 启动成功,浏览器打开localhost:8080

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值