我試圖運行一個彈簧啓動應用程序。我從教程中下載了一段代碼,所以我知道代碼的作用。當我運行我的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中,他明確指出,默認是任何請求類型,並且沒有任何方法適用於他。 –