无法获取Sringboot应用程序来查看我的ReactJS应用程序

时间:2019-02-18 15:09:43

标签: java reactjs spring-boot

我在本地React(本地主机:3000)中构建了一个UI,并构建了一个生产应用。现在我必须创建一个WAR文件放入服务器,因此我在Springboot中创建了一个非常简单的Web应用程序。但是,我的控制器未拾取我的.jsp(或.html-设置为无关紧要。)

控制器:

@Controller
public class MainController {
      @RequestMapping("/")
      public String hello(Model model) {
        model.addAttribute("message", "Hello from the controller");
        return "mainApp";
      }
}

Sring Boot应用

@SpringBootApplication
public class WebappApplication extends WebMvcConfigurerAdapter {

    public static void main(String[] args) {
        SpringApplication.run(WebappApplication.class, args);
    }

}

申请道具。

spring.mvc.view.prefix=/WEB-INF/pages
spring.mvc.view.suffix=.jsp
server.port=8090

文件夹:

enter image description here

POM文件:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
        <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.7.RELEASE</version>
    </parent>


    <groupId>---</groupId>
    <artifactId>---</artifactId>
    <version>1.0.0</version>
    <packaging>war</packaging>

    <name>UI</name>

    <description>--</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <!-- Spring Boot -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>   

        <!-- Actuator -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

        <!-- AOP -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>


        <!-- Common DBCP2 connection pool -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-dbcp2</artifactId>
        </dependency>

        <!-- HttpClient -->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
        </dependency>

        <!-- spring-webmvc -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
        </dependency>   

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-java8</artifactId>
        </dependency>


        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>4.11</version>
          <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>  
    </build>
</project>

我得到以下内容

Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.

Mon Feb 18 10:12:13 EST 2019
There was an unexpected error (type=Not Found, status=404).
No message available

0 个答案:

没有答案