feat(controller): 添加Demo控制器并更新依赖配置

- 创建了DemoController类,提供/hello接口返回"Hello World!"
- 在pom.xml中添加spring-boot-starter核心依赖
- 将spring-boot-starter-webmvc替换为spring-boot-starter-web
- 将spring-boot-starter-webmvc-test替换为spring-boot-starter-test
- 添加spring-boot-starter-actuator监控组件
- 注释掉数据库相关依赖以简化项目配置
This commit is contained in:
gxl 2026-06-02 11:24:39 +08:00
parent 15c1e6a11f
commit f4dbb3a80e
2 changed files with 25 additions and 3 deletions

14
pom.xml
View File

@ -30,13 +30,17 @@
<java.version>17</java.version> <java.version>17</java.version>
</properties> </properties>
<dependencies> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<!-- <dependency>--> <!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>--> <!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-jdbc</artifactId>--> <!-- <artifactId>spring-boot-starter-jdbc</artifactId>-->
<!-- </dependency>--> <!-- </dependency>-->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webmvc</artifactId> <artifactId>spring-boot-starter-web</artifactId>
</dependency> </dependency>
<!-- <dependency>--> <!-- <dependency>-->
<!-- <groupId>org.mybatis.spring.boot</groupId>--> <!-- <groupId>org.mybatis.spring.boot</groupId>-->
@ -56,10 +60,14 @@
<!-- </dependency>--> <!-- </dependency>-->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webmvc-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!-- <dependency>--> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.mybatis.spring.boot</groupId>--> <!-- <groupId>org.mybatis.spring.boot</groupId>-->
<!-- <artifactId>mybatis-spring-boot-starter-test</artifactId>--> <!-- <artifactId>mybatis-spring-boot-starter-test</artifactId>-->
<!-- <version>4.0.1</version>--> <!-- <version>4.0.1</version>-->

View File

@ -0,0 +1,14 @@
package com.example.demo.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController()
@RequestMapping("/demo")
public class DemoController {
@RequestMapping("/hello")
public String demo() {
return "Hello World!";
}
}