【问题标题】:Spring Boot doc is out of dateSpring Boot 文档已过期
【发布时间】:2017-11-29 13:55:18
【问题描述】:

https://spring.io/guides/gs/spring-boot/

据我所知,这已经过时了。

github repo 不存在,所以我使用了前面提到的 initilizr 并将其导入 intellij。

然后我尝试创建一个新的 java 类,就像教程第一部分在 https://spring.io/guides/gs/spring-boot/#_create_a_simple_web_application 中所说的那样

但直截了当,提供的代码中的导入失败:

package hello;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;

@RestController
public class HelloController {

    @RequestMapping("/")
    public String index() {
        return "Greetings from Spring Boot!";
    }

}

我用谷歌搜索了一下,显然(但我可能误解了。)RestController 已被Controller 弃用?

那么RequestMapping呢?

如何设置基本的测试休息服务。

PS:在initilizr(https://start.spring.io/)中,我选择了Spring Boot 2.0.0 M6

【问题讨论】:

  • 您可以将@RestController@RequestMapping@Controller 结合使用,因为@RestController 在内部标有@ResponseBody@Controller,因此已经有资格进行组件扫描。使用@RestController 更简洁。
  • 那一定是你的问题...... Github repo 在这里......你对@RestController的理解是错误的。
  • 嗯。 git pull 失败了,所以我认为 repo 不存在,但确实存在。

标签: spring-boot


【解决方案1】:

在您的pom.xml 文件中,将第一行<artifactId> 更改为:

<artifactId>spring-boot</artifactId>

可能会有所不同(对我来说是&lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;)。

有了这个,你的导入应该是可用的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-03-19
    • 2021-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多