繁体   English   中英

Whitelabel错误页面,在springboot中未执行其他URL

[英]Whitelabel Error Page, rest urls not executed in springboot

Spring Boot应用程序开发的新功能。 我将应用程序作为Java应用程序运行,并收到以下错误。 该应用程序已成功部署,我不知道为什么会出现此错误...击败了我的头..谢谢您的提前帮助。

Whitelabel Error Page此应用程序没有针对/ error的显式映射,因此您将其视为后备。 IST 2019年7月13日星期六21:37:31发生意外错误(类型=未找到,状态= 404)。 无讯息

尝试给出堆栈溢出但没有帮助的解决方案。 如果我在这里做错了什么,请您能帮助我。

package com.cpi.poc.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cpi.poc.service.IService;

@RestController
@RequestMapping(value ="/test")
@ComponentScan(basePackages = "com.cgi.poc")
public class TestController {

    @Autowired
    IService service;
    @RequestMapping(value = "/greet" , method = RequestMethod.GET)
    public String testService(){
        String result = service.greet();
        return result;
    }

}

pom.xml

<?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.21.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.cgi.poc</groupId>
    <artifactId>test</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>test</name>
    <description>Demo project for Spring Boot</description>

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

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

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


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

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

检查您是否上课:

@SpringBootApplication
@ComponentScan("com.cgi.poc")
@ComponentScan
public class Application {

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

如果您具有上述类,则无需在控制器上进行组件扫描。 使用lsof命令验证Java服务是否在非端口上运行。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM