为什么我的springboot 404

HelloController.java

package com.fty.Controller;

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

@RestController
public class HelloController {
    @RequestMapping(value="/hello")
    public String hello(){
        System.out.println("hello");
        return "hello world";
    }
}

GirlApplication.java

package com.fty.girl;

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

@SpringBootApplication
public class GirlApplication {

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

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>2.1.1.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.fty</groupId>
    <artifactId>girl</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>girl</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-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

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


</project>

目录结构

  • src

    • main

      • java

        • com.fty.Controller

          • HelloController.java
        • girl

          • GirlApplication.java

控制台输出

没有类似这句的日志输出
2018-12-11 12:27:54.200 INFO 6008 — [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped “{[/error]}”

2018-12-11 12:24:28.945  INFO 10568 --- [           main] com.fty.girl.GirlApplication             : Starting GirlApplication on User with PID 10568 (C:\Users\Administrator\IDEAworkspace\girl\target\classes started by user in C:\Users\Administrator\IDEAworkspace\girl)
2018-12-11 12:24:28.954  INFO 10568 --- [           main] com.fty.girl.GirlApplication             : No active profile set, falling back to default profiles: default
2018-12-11 12:24:32.243  INFO 10568 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2018-12-11 12:24:32.284  INFO 10568 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2018-12-11 12:24:32.284  INFO 10568 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/9.0.13
2018-12-11 12:24:32.305  INFO 10568 --- [           main] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jdk1.8.0_101\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\apache-maven-3.3.9\bin;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Acer\abFiles\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Users\德玛\AppData\Local\Programs\;C:\Program Files\Git\cmd;C:\Program Files\Java\jdk1.8.0_101\bin;C:\Program Files (x86)\GtkSharp\2.12\bin;.]
2018-12-11 12:24:32.556  INFO 10568 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-12-11 12:24:32.556  INFO 10568 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 3439 ms
2018-12-11 12:24:33.005  INFO 10568 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2018-12-11 12:24:33.407  INFO 10568 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2018-12-11 12:24:33.412  INFO 10568 --- [           main] com.fty.girl.GirlApplication             : Started GirlApplication in 5.428 seconds (JVM running for 6.395)

求各位大佬指导一下问题出在哪 谢谢

猜你喜欢

转载自blog.csdn.net/weixin_37966622/article/details/84953108
404