java - Spring Boot 引用指南 - 从 app.groovy 示例中获取 404

标签 java spring-boot

我关注Spring Boot Reference Guide并收到此错误

HTTP Status [404] – [Not Found]
Type Status Report
Message /
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.

这是代码

@RestController
class ThisWillActuallyRun {
    @RequestMapping("/")
    String home() {
        "Hello World!"
    }
}

我运行的命令。

spring run app.groovy

我得到的控制台日志。


  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.5.4.RELEASE)

2017-07-21 14:37:37.474  INFO 47637 --- [       runner-0] o.s.boot.SpringApplication               : Starting application on MacBook-Pro-2016.local with PID 47637 (started by moss in /Users/moss/java_ws/hello)
2017-07-21 14:37:37.477  INFO 47637 --- [       runner-0] o.s.boot.SpringApplication               : No active profile set, falling back to default profiles: default
2017-07-21 14:37:37.659  INFO 47637 --- [       runner-0] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@3a0184b7: startup date [Fri Jul 21 14:37:37 ICT 2017]; root of context hierarchy
2017-07-21 14:37:38.831  INFO 47637 --- [       runner-0] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-07-21 14:37:38.844  INFO 47637 --- [       runner-0] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2017-07-21 14:37:38.846  INFO 47637 --- [       runner-0] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.15
2017-07-21 14:37:38.923  INFO 47637 --- [ost-startStop-1] org.apache.catalina.loader.WebappLoader  : Unknown loader org.springframework.boot.cli.compiler.ExtendedGroovyClassLoader$DefaultScopeParentClassLoader@c0454ed class org.springframework.boot.cli.compiler.ExtendedGroovyClassLoader$DefaultScopeParentClassLoader
2017-07-21 14:37:38.950  INFO 47637 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2017-07-21 14:37:38.951  INFO 47637 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1296 ms
2017-07-21 14:37:39.020  INFO 47637 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-07-21 14:37:39.605  INFO 47637 --- [       runner-0] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2017-07-21 14:37:39.674  INFO 47637 --- [       runner-0] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2017-07-21 14:37:39.678  INFO 47637 --- [       runner-0] o.s.boot.SpringApplication               : Started application in 12.556 seconds (JVM running for 14.572)

我做错了什么吗?

最佳答案

我只是使用 sdkman 切换回 Spring CLI v1.5.3.RELEASE 就可以了。

关于java - Spring Boot 引用指南 - 从 app.groovy 示例中获取 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45232100/

相关文章:

hibernate - 使用Postgresql文本类型在Grails域类中映射Clob类型

java - 在 Apache POI 中创建 CellStyle 库

java - spring boot:无法解析导入的org.springframework.jdbc.core.JdbcTemplate

java - 简单的退出按钮不起作用

java - IE 中小程序出现间歇性 'access denied' 'accessClassInPackage.sun.plugin.javascript' 错误

java - 在外部 Tomcat 中部署 war 时,Springboot 端点失败

java - 如何编写正则表达式来匹配 yaml 文件中的键?

java - 如何将一组 java 对象表示为数据库中其他对象的字段?

spring-boot - 带有 swagger UI 的 Spring Boot 提供空页面

java - Spring Boot : only for web application development?