SpringBoot入门程序

2025-05-19 05:40:54

1、创建一个Maven工程:

SpringBoot入门程序

2、导入SpringBoot相关的依赖包:<parent争犸禀淫> <groupId>org.springframework.boot</groupI颊俄岿髭d> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.0.RELEASE</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies>

SpringBoot入门程序

4、编写相关的Controller、Service。package com.gwolf.controller;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.ResponseBody;@Controllerpublic class HelloController { @ResponseBody @RequestMapping("/hello") public String hello() { return "hello World!"; }}

SpringBoot入门程序

6、在浏览器中访问地址:http://localhost:8080/hello

SpringBoot入门程序
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢