我试图运行一个弹簧启动应用程序。我从教程中下载了一段代码,所以我知道代码的作用。当我运行我的jar文件时,它看起来像我在端口8080上运行的应用程序,但我仍然得到404的任何URL,我从来没有得到春白标签页。我检查了我没有运行任何其他端口8080,并启动并运行了服务器。启动jar时弹簧启动错误404
我不知道为什么我的应用程序没有响应。
package com.virtualpairprogrammers;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* Created by masn on 2017-04-01.
*/
@RestController
public class HelloController {
@RequestMapping("/hello")
public String sayHello(){
return "Hello";
}
}
enter code here
包com.virtualpairprogrammers;
import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication 公共类FleetmanApplication {
public static void main(String[] args) {
SpringApplication.run(FleetmanApplication.class, args);
}
}
enter code here
http://maven.apache.org/xsd/maven-4.0.0.xsd“> 4.0 .0
<groupId>com.virtualpairprogrammers</groupId>
<artifactId>fleetman</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>fleetman</name>
<description>VPP´s Fleet Management Application</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<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>
嗯,至少我应该得到的白色标签页?是的,我尝试添加控制器.... –
对不起。现在检查,没有做任何设置,并按照教程,它在视频100%相同的指示。 –
那么在vidoe中,他明确指出,默认是任何请求类型,并且没有任何方法适用于他。 –