Spring 没有依赖性的端点 Spring-Boot-Data-REST-Starter

Spring endpoints without dependency Spring-Boot-Data-REST-Starter

我有一个存储库和控制器,

@RestController
public class PersonController {

    @Autowired
    PersonRepository repository;

    @GetMapping("/people")
    public Iterable<Person> getPeople() {
        return repository.findAll();

    }
    @PostMapping("/people")
    public void addPerson(@RequestBody Person person) {
        repository.save(person);
    }
}

我想创建 endpoint /people 但如果没有依赖项 Spring-Boot-Data-REST-Starter,这将无法工作。 问题是:是否可以在没有 Spring-Boot-Data-REST-Starter 依赖项的情况下创建端点?

这是我的依赖项:

<dependencies>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-jpa</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
    <groupId>com.h2database</groupId>
    <artifactId>h2</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
</dependency>

我有一条消息:已启动应用程序,但进程已结束,退出代码为 0,因此没有任何进展。

我应该添加这个依赖:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>