Java spring引导应用程序未在Tomcat中配置的端口号上启动

Java spring引导应用程序未在Tomcat中配置的端口号上启动,java,spring,spring-boot,Java,Spring,Spring Boot,我正在spring工具套件中运行示例spring引导应用程序。 配置端口后,我无法从浏览器启动应用程序。我得到404未找到错误。 tomcat上的Spring boot运行正常 应用程序属性 你好。问候=很高兴见到你 server.port=9874 谁能帮我纠正一下这个问题吗 package demo; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigur

我正在spring工具套件中运行示例spring引导应用程序。 配置端口后,我无法从浏览器启动应用程序。我得到404未找到错误。 tomcat上的Spring boot运行正常

应用程序属性

你好。问候=很高兴见到你

server.port=9874

谁能帮我纠正一下这个问题吗

package demo;

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

@SpringBootApplication
public class HelloBootApplication {

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


package demo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    @Autowired
    HelloProperties props;

    @RequestMapping("/hello")
    public String hello(@RequestParam String name) {
        return props.getGreeting()+name;
    }

}

package demo;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Component
@ConfigurationProperties("hello")
public class HelloProperties {
    private String greeting = "Welcome ";

    public String getGreeting() {
        return greeting;
    }

    public void setGreeting(String greeting) {
        this.greeting = greeting;
    }
}

2018-07-22 17:17:32.798  INFO 11824 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-07-22 17:17:32.952  INFO 11824 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2018-07-22 17:17:33.000  INFO 11824 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 9874 (http) with context path ''
2018-07-22 17:17:33.006  INFO 11824 --- [           main] demo.HelloBootApplication                : Started HelloBootApplication in 2.083 seconds (JVM running for 2.862)
这是spring启动应用程序,在下面的链接中找不到404
您的url错误。您必须使用RequestParam名称调用url


使用此url

您的url错误。您必须使用RequestParam名称调用url


使用此url

而不查看代码我如何为您的问题提供解决方案?请提供导致问题的代码仅使用指定的“/hello”上下文路径进行尝试,因此您需要请求它,而不仅仅是我也尝试过,但404错误是获取服务器运行时没有任何错误我认为,我是否错过了任何其他配置。在没有看到代码的情况下,我如何为您的问题提供解决方案?请提供导致问题的代码仅使用指定的“/hello”上下文路径进行尝试,因此您需要请求它,而不仅仅是我也尝试过,但404错误是获取服务器运行时没有任何错误我认为,我是否错过了任何其他配置。在netstat上,一个命令[TCP[::]:9874[::]:0正在侦听],我看到这样的情况,我的移植是否被任何其他服务使用?我已经阅读了这篇文章,但我无法找出问题所在。在netstat-an命令[TCP[:]:9874[:]:0侦听]上,我看到这样的情况,我的移植是否被任何其他服务使用?我已经阅读了本文,但我无法找出问题所在。