-
创建Maven项目
-
pom.xml中加入
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.4.1</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build>
-
文件目录结构
-
MainApplication
@SpringBootApplication public class MainApplication { public static void main(String[] args) { SpringApplication.run(MainApplication.class, args); } }
-
HelloController
@RestController public class HelloController { @RequestMapping("/") public String index(){ return "Hello, Spring Boot!"; } }
-
运行MainApplication
SpringBoot——HelloWorld
最新推荐文章于 2022-04-27 21:43:50 发布