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

书接上回

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

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

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

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

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

<!-- junit 依赖( junit 测试必须) -->
<dependency>
<groupId> junit </groupId>
<artifactId> junit </artifactId>
<version> 3.8.1 </version>
<scope> test </scope>
</dependency>

 

 去修改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项目就差不多了!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
使用IDEA创建Spring Boot项目时,可以选择使用Maven来进行项目的构建和管理。首先,你需要在IDEA中安装好Maven插件。 接下来,按照以下步骤来创建Spring Boot项目: 1. 打开IDEA,选择"File"菜单,然后选择"New",再选择"Project"。 2. 在弹出的对话框中,选择"Maven"作为项目类型,点击"Next"。 3. 在下一个对话框中,填写项目的基本信息,例如项目的Group ID、Artifact ID和Version等。这些信息将在生成项目的pom.xml文件中使用。点击"Next"。 4. 在下一个对话框中,选择你想要创建Spring Boot项目的初始配置。你可以选择不同的配置,比如Web应用程序、RESTful服务等。选择完毕后,点击"Finish"。 5. 等待IDEA完成项目的初始化和构建过程。 通过以上步骤,你就成功使用Maven创建了一个Spring Boot项目。在项目中,你可以使用Maven管理依赖、构建和打包等操作。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [idea使用maven创建springboot项目](https://blog.csdn.net/cc365/article/details/131181963)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *3* [IDEA使用Maven搭建SpringBoot项目](https://blog.csdn.net/yuanmuchunpin/article/details/127652386)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值