Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 白色标签错误页,未在springboot中执行rest URL_Java_Spring Boot_Pom.xml - Fatal编程技术网

Java 白色标签错误页,未在springboot中执行rest URL

Java 白色标签错误页,未在springboot中执行rest URL,java,spring-boot,pom.xml,Java,Spring Boot,Pom.xml,spring启动应用程序开发的新功能。我将应用程序作为java应用程序运行,并得到以下错误。应用程序已成功部署,我不知道为什么会出现此错误。。。打我的头。。提前谢谢你的帮助 此应用程序没有显式映射的白标签错误页 /错误,因此您将此视为一种回退。星期六7月13日21:37:31 2019发生意外错误(类型=未找到,状态=404)。不 信息可用 尝试解决堆栈溢出问题,但没有帮助。如果我在这里做错了什么,你能帮我一下吗 package com.cpi.poc.controller; import o

spring启动应用程序开发的新功能。我将应用程序作为java应用程序运行,并得到以下错误。应用程序已成功部署,我不知道为什么会出现此错误。。。打我的头。。提前谢谢你的帮助

此应用程序没有显式映射的白标签错误页 /错误,因此您将此视为一种回退。星期六7月13日21:37:31 2019发生意外错误(类型=未找到,状态=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>

4.0.0
org.springframework.boot
spring启动程序父级
1.5.21.发布
com.cgi.poc
测试
0.0.1-快照
测试
SpringBoot的演示项目
1.8
org.springframework.boot
SpringBootStarterWeb
org.springframework.boot
弹簧启动机tomcat
假如
org.springframework.boot
弹簧起动试验
测试
org.springframework.boot
springbootmaven插件

检查您是否有课程:

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

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}
如果您具有上述类,则无需在控制器上放置组件扫描。
使用lsof命令验证您的java服务是否在not上的端口上运行。

检查您是否有类:

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

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}
如果您具有上述类,则无需在控制器上放置组件扫描。
使用lsof命令验证java服务是否在not上的端口上运行。

是否向
http://localhost:/test/greet
?在向
http://localhost:/test/greet
?您能用imports添加主类的代码吗谢谢您的回复。。我错过了服务类中的服务和组件注释。。这就是为什么我很难运行应用程序的原因。谢谢你的回复。。我错过了服务类中的服务和组件注释。。这就是为什么我很难运行应用程序。。