首页 新闻 会员 周边

Spring boot启动成功但是报404:The origin server did not find a current representation for the target resource or is not willing to disclose that one exists

0
悬赏园豆:50 [待解决问题]

环境:
  win10 64bit
  安装的JDK 1.6 32bit
  绿色版JDK 1.8 64bit
  STS 3.8.4.RELEASE/3.9,STS都是使用的JDK是1.8(启动和运行)
  spring boot version:1.5.7
  hosts:

  # localhost name resolution is handled within DNS itself.

  # 127.0.0.1 localhost
  # ::1 localhost
  172.20.207.252 s1
  172.20.207.252 s2
  172.20.207.252 s3
  172.20.207.252 s4
  172.20.207.252 s5

DemoApplication.java

package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
//@RestController
@SpringBootApplication
public class DemoApplication {
  public static void main(String[] args) {
    SpringApplication.run(DemoApplication.class, args);
  }
}

TestController.java

package com.example.demo.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class TestController {
  @RequestMapping("/hello")
  public String sayHi(){
    return "hello";
  }
}

application.properties

#server.port=1001
#server.context-path=/test

工程文件目录截图:

启动日志:

复制代码
[           main] com.example.demo.DemoApplication         : Starting DemoApplication on YIXIUQUAN-PC with PID 7596 (D:\WorkSpace\STS_workspace_3.9\demo\target\classes started by yxq in D:\WorkSpace\STS_workspace_3.9\demo)
[           main] com.example.demo.DemoApplication         : No active profile set, falling back to default profiles: default
[           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@71623278: startup date [Mon Sep 25 10:19:16 CST 2017]; root of context hierarchy
[           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
[           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
[           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.20
[ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
[ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 961 ms
[ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
[           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
[           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
[           main] com.example.demo.DemoApplication         : Started DemoApplication in 1.565 seconds (JVM running for 2.194)
复制代码

问题描述:

加上contextpath也是报这个错误,加上工程名称demo(contextPath不配置)也报这个错误

不使用localhost使用IP地址或者127.0.0.1也报这个错误

同样的工程在别人的环境下可以正常运行(本机使用IDEA启动也可以正常访问)  直接使用http://localhost:8080/hello 返回hello 如图:

上周一二还正常,周三四出的问题,当时我正在用eureka/feign和hystrix

yixiuquan的主页 yixiuquan | 初学一级 | 园豆:-36
提问于:2017-09-25 10:32
< >
分享
所有回答(2)
0

找到一个解决方法:把maven本地库的所有内容全部删除,然后重新更新下载jar包后,再启动,就好了

针对我的这个环境(安装JDK是1.6 32bit,而maven是3.0.4(即使用的JDK1.6),STS使用的解压的JDK1.8(运行和启动)),不知道还有没有更好的解决方法

yixiuquan | 园豆:-36 (初学一级) | 2017-09-25 17:46
0

您好,我遇到了您描述的问题,想详细的知道您的具体操作.方便详细说明一下么?或者您留一个QQ,劳烦了,感谢.

只修电脑不过夜 | 园豆:202 (菜鸟二级) | 2018-02-28 17:28

把maven本地库的jar全部删除,重新下载新的,出现这个问题应该是下载的jar不兼容导致出现了问题,如果不行,发下你的QQ 我加你

支持(0) 反对(0) yixiuquan | 园豆:-36 (初学一级) | 2018-02-28 17:38

@yixiuquan: 感谢,成功解决了问题,刚刚看到消息.

支持(0) 反对(0) 只修电脑不过夜 | 园豆:202 (菜鸟二级) | 2018-03-01 14:37
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册