我试图设置一个带有反应的spring boot web应用程序。我尝试按照一些教程,引导我看到如下代码:
TechtoolApplication.java
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class TechtoolApplication {
public static void main(String[] args) {
SpringApplication.run(TechtoolApplication.class, args);
}
}
IndexController.java:
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class IndexController {
@RequestMapping(value = "/")
public String index() {
return "index";
} }
App.js
import React from 'react';
export default class App extends React.Component {
render() {
return (
<h1>Test</h1>
);
}
}
index.js
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(
<App/>,
document.getElementById('root')
);
的index.html
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head lang="en">
<meta charset="UTF-8"/>
<title>ReactJS + Spring Data REST</title>
<link rel="stylesheet" href="/main.css" />
</head>
<body>
<div id="root"></div>
<script src="built/bundle.js"></script>
</body>
</html>
application.yml
spring:
datasource:
url: jdbc:mysql:/localhost:3306/techtool
username: root
password: ***********
data:
rest:
base-path: /api
security:
basic:
enabled: false
我的问题是,我总是得到一个WhiteLabel错误,我不知道为什么,更不用说如何纠正我的错误。谢谢冷杉帮助我!
编辑:添加了目录树
├───main
├───java
│ └───com
│ ├───Techtool
│ └───TechtoolApplication
│ └───IndexController
└───resources
├───app
│ └───App.js
│ └───index.js
└───templates
└───index.html