스프링 부트 응용 프로그램을 실행하려고하지만 404 오류를 찾을 수 없습니다.스프링 부트 404 찾을 수 없음 오류
프로젝트 구조 :
src/
+- main/
+- java/
| + com/
| + demo/
| SpringBootDemo.java
| + controller/
| HomeController.java
+- resources/
| application.yml
src/
+- main/
+- webapp/
+- WEB-INF/
+- pages/
| home.jsp
HomeController.java
package com.demo.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class HomeController {
@GetMapping("/")
public String getHome() {
System.out.println("Controller");
return "home";
}
}
application.yml
server:
port: 8080
spring:
mvc:
view:
prefix: /WEB-INF/pages/
suffix: .jsp
build.gradle
buildscript {
ext {
springBootVersion = '1.5.6.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'application'
mainClassName = 'com.demo.SpringBootDemo'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
// In this section you declare where to find the dependencies of your project
repositories {
mavenCentral()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
testCompile('org.springframework.boot:spring-boot-starter-test')
compile('org.springframework.boot:spring-boot-starter-parent')
compile('javax.servlet.jsp.jstl:javax.servlet.jsp.jstl-api')
}
jar {
manifest {
attributes(
'Main-Class': 'com.demo.SpringBootDemo'
)
}
}
0,123,516
SpringBootDemo.java
package com.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication(scanBasePackages="com.demo")
public class SpringBootDemo {
public static void main(String[] args) {
SpringApplication.run(SpringBootDemo.class, args);
}
}
home.jsp이
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hello</title>
</head>
<body>
Hello World
</body>
</html>
내가 코드를 실행하려고, 그것은
Controller
로 출력을 보여줍니다하지만이 Whitelabel Error Page
을 제공합니다 때 http://localhost:8080/
당신이이 글을 읽을 적이 있습니까? https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-jsp-limitations 애플리케이션을 어떻게 만들고 실행합니까? 당신의 gradle 빌드에 전쟁 플러그인이 적용된 것을 볼 수 없으므로 문서에서이 중요한 경고를 무시했을 것입니다. " –