栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

maven创建Spring boot项目2.0(升级版)

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

maven创建Spring boot项目2.0(升级版)

书接上回

手把手教你用maven创建springboot项目(开发环境为vscode)_weixin_48456383的博客-CSDN博客

我们来正式创建一个简单的项目工程

这个页面还记得吧,不记得的去翻上面的链接,我们从这里出发(只要这一步,前面的那些generate啥的咱也不要了)。把这个zip文件下下来。

解压到你的空Java工程中去,如下所示

老规矩,pom.xml中它还是没有junit,在dependencies里给他加上去

junit junit 3.8.1 test

 

 去修改DemoApplication.java

改成如下

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 DemoApplication {

public static void main(String[] args) {

SpringApplication.run(DemoApplication.class, args);

}

@GetMapping("/hello")

public String hello(@RequestParam(value = "name", defaultValue = "World") String name) {

return String.format("Hello %s!", name);

}

}

长这样:

然后你去springboot根目录去运行

mvn spring-boot:run

等一会儿,不出意外你应该是这个页面

 那这就运行成功了!

点击这个url应该就能看到hello world了。

http://localhost:8080/hello

到这里,创建spring boot项目就差不多了!

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/315136.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号