弹簧靴2&;Spring 5服务index.html时出错

弹簧靴2&;Spring 5服务index.html时出错,spring,spring-boot,spring-webflux,Spring,Spring Boot,Spring Webflux,我有一个用Kotlin编写的非常简单的Spring Boot应用程序 @SpringBootApplication class DemoApplication fun main(args: Array<String>) { SpringApplication.run(DemoApplication::class.java, *args) } @Controller class HomeController { @GetMapping("/") fun h

我有一个用Kotlin编写的非常简单的Spring Boot应用程序

@SpringBootApplication
class DemoApplication

fun main(args: Array<String>)
{
    SpringApplication.run(DemoApplication::class.java, *args)
}


@Controller
class HomeController
{
    @GetMapping("/")
    fun home() = "index.html"
}
@springboot应用程序
类演示应用程序
趣味主线(args:Array)
{
run(DemoApplication::class.java,*args)
}
@控制器
类家庭控制器
{
@GetMapping(“/”)
fun home()=“index.html”
}
resource/public
文件夹中,我有
index.html

但是,当我打开浏览器并键入
localhost:8080/
时,我得到一个错误
java.lang.IllegalStateException:无法在运行的Spring引导控制台中解析名为'index.html'
的视图

我只想要尽可能少的代码来服务index.html。不应该那么难吗?;)


注意:我使用的是SpringWebreactive

是否需要添加
home()
消息?我认为index.html即使没有它也可以访问。首先,我怀疑您是否需要该方法;其次,如果您返回的内容应该是
index
,它将由视图解析程序解析为适当的模板。是否需要添加
home()
消息?我认为index.html即使没有它也可以访问。首先,我怀疑您是否需要该方法;其次,如果您返回的内容应该是
index
,它将由视图解析器解析为适当的模板。