spring boot 项目在eclipse中启动后能正常访问 idea启动正常但返回404

zxl890902 2017-02-23 08:44:48
spring boot 项目在eclipse中启动后能正常访问 idea启动正常但返回404。
idea中启动时没有报错。debug的话也能正确进入controller。但是页面返回404

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Thu Feb 23 08:31:53 CST 2017
There was an unexpected error (type=Not Found, status=404).
No message available
...全文
2389 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
徐新龙 2017-12-22
  • 打赏
  • 举报
回复
可以参考一下http://blog.csdn.net/baidu_29092471/article/details/56675810
  • 打赏
  • 举报
回复
1.引入依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> 2,在application.properties中配置模板引擎 3. 配置你所在的页面地址
kjop78 2017-11-23
  • 打赏
  • 举报
回复
没配置视图解析器之前的报错 2017-11-23 20:47:31.665 ERROR 10648 --- [nio-8080-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: Error resolving template "index2", template might not exist or might not be accessible by any of the configured Template Resolvers] with root cause org.thymeleaf.exceptions.TemplateInputException: Error resolving template "index2", template might not exist or might not be accessible by any of the configured Template Resolvers 发现配置文件没点B用
kjop78 2017-11-23
  • 打赏
  • 举报
回复





搞了2个半小时,最后是建立了errorpage后,会把错误信息打印到console里,发现配置文件那2行配置没一点卵用
不管怎么配,都是去templates下找

果断用老方法,写视图解析器可以了
GJH____ 2017-10-26
  • 打赏
  • 举报
回复
检查pom文件里,是否加入 maven插件

           <plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<version>1.5.8.RELEASE</version>
				<configuration>
					<mainClass>${mainClass}</mainClass>
					<layout>ZIP</layout>
				</configuration>
				<executions>
					<execution>
						<goals>
							<goal>repackage</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
然后再install一下 还要 记得选【工作目录
qq_34994724 2017-10-19
  • 打赏
  • 举报
回复
同问
小土豆子额 2017-06-29
  • 打赏
  • 举报
回复
我也是这样,现在只能使用命令spring-boot:run来启动项目
hui_fei 2017-06-26
  • 打赏
  • 举报
回复
有没有idea大神给看看,我的也是这个问题,困扰好久了
学贵有恒01 2017-06-06
  • 打赏
  • 举报
回复
我的也是这样,被这个问题困扰了好几天,还是没解决。。。
乐百川 2017-02-25
  • 打赏
  • 举报
回复
估计是servlet context问题,Eclipse默认路径是http://localhost:8080/project-name/,IDEA路径是http://localhost:8080/,如果用JSP的话所有链接改为使用<a href="<c:url="/index"/>" >链接</a>这样的形式,Java EE容器会自动组合出正确的URL
弗兰卡 2017-02-23
  • 打赏
  • 举报
回复
你的返回写错了吧,你是怎么返回的,如果直接 return "index",那就默认找到 resources/static/templates/index.html

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧