小编Ank*_*ane的帖子

HTTP 状态 404 - 创建 springBoot 应用程序时未找到

这是一个 springboot 应用程序。它运行完美,但没有得到输出(它在浏览器中显示 HTTP 状态 404 错误)

pom.xml

<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>
  <groupId>com.exaample.demo</groupId>
  <artifactId>SpringBootMaven</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>Maven spring boot project</name>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.9.RELEASE</version>
    </parent>

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

    <properties>
        <java.version>1.8</java.version>   
    </properties>
</project>
Run Code Online (Sandbox Code Playgroud)

Springboot启动类 Main方法

package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class WebMainMethod {

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

    }

}
Run Code Online (Sandbox Code Playgroud)

控制器在主类之后加载

**Rest Controller**


package com.example.demo.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    @RequestMapping("/hello")
    public String sayHi() {
        return "Hi"; …
Run Code Online (Sandbox Code Playgroud)

java spring spring-mvc spring-boot

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

java ×1

spring ×1

spring-boot ×1

spring-mvc ×1