0
在我的春天启动的应用程序404错误,我有以下pom.xml
:弹簧引导错误:在加载模板
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
的控制器我有如下简单的一个:
@Controller
public class ThyemeleafController {
@RequestMapping("/")
public String home() {
return "home";
}
}
然后我有一个简单的home.html
在src/main/resources/templates
其中包含helloWorld
。但是当我运行的应用程序并进入网址:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Fri Sep 29 17:15:13 GMT-12:00 2017
There was an unexpected error (type=Not Found, status=404).
No message available
你不需要@ComponentScan(“com.eventer.controller”)与春季启动。 –
那么,它是如何解决我的问题? –
您必须遵循Java推荐的包命名约定。 https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-structuring-your-code.html –