spring Boot报错 之五种(不打包运行)
来源:互联网 发布:创作漫画的软件 编辑:程序博客网 时间:2024/05/14 18:09
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
其一:
之前百度,google,必应,都TM 不好使 都是是其他人自己手欠的原因,低级原因(打错字),但没想到的是自己也犯低级错误
@SpringBootApplication 这个注解的类要放在最外围的包里,一遍能管理到其他 controller , 如图
红框里的就是 spring Boot 的配置应用,要放在绿框的外面包里
其二:
有配置properties资源文件 键值对 像这样的
spring.view.prefix: /WEB-INF/jsp/
spring.view.suffix: .jsp
应该改为
spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp
(注意默认的配置key 不要写错了)
spring boot appliaction配置文件默认配置项
其三:
properties配置资源文件 引用文件(toolbox.xml) 但是项目里没有这个文件 找不到文件
spring.velocity.toolbox-config-location = toolbox.xml
其四:访问url 的问题
说说自己干了什么傻逼事这是我配置的应用类
package com.spring.boot;import java.util.Date;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.ResponseBody;import org.springframework.web.bind.annotation.RestController;@SpringBootApplication//等于@Configuration,@EnableAutoConfiguration,@ComponentScan@RestController//等于@Controller和@ResponseBody注解。//@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})//Spring Boot会创建默认的内存数据库的数据源DataSource,如果你自己创建了DataSource,Spring Boot就不会创建默认的DataSourcepublic class DemoApplication {public static void main(String[] args) {SpringApplication.run(DemoApplication.class, args);//或者/*SpringApplication application = new SpringApplication(DemoApplication.class);application.run(args);*///或者/*new SpringApplicationBuilder() .showBanner(false) .sources(Application.class) .run(args);*/}@RequestMapping("/")String home() {System.out.println(2324234); return "index";}@RequestMapping("/now")String hehe() { return "现在时间:" + (new Date()).toLocaleString();}}
项目名叫 jxTest ,写惯了web 项目访问的小伙伴都懂 http://localhost:8080/jxTest/now 这样写 理所当然,但是
spring boot 就是跟人家不一样, 正确的写法应该是 http://localhost:8080/now
(update )
其五:
正常情况下,配置视图的前后缀是没有问题的, 大多数情况为了安全, 把页面想放到WEB-INF 下 如果pom文件没有添加这一句
<!-- 配置 页面的记得引用 这个包 , 直接返回json 不需要 --> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-jasper</artifactId> <scope>provided</scope> </dependency>
也是会报上面的错
以上总结自己所查询的几个出现这个错误的原因
- spring Boot报错 之五种(不打包运行)
- spring boot 原理、demo 与打包运行
- spring boot打包jar直接运行
- Spring boot 的打包和运行
- Spring boot 第一个DEMO 运行报错
- Spring Boot报错问题解决
- spring boot启动报错
- spring boot启动报错
- Spring Boot 报错分析
- Spring boot 启动报错
- spring boot 打包成jar 在服务器上运行
- Spring Boot 运行原理之自动配置
- spring boot使用quartz定时器启动报错,但是定时器正常运行
- spring boot maven打包时报错
- 打包Spring Boot工程
- spring boot 打包war
- Spring Boot打包总结
- Spring Boot 打包war
- MVC模式
- 水灾
- Eoj 3318&3326 最大的排列 刚好坐满的公交车
- OpenJudge-【3528】:最小新整数
- CODE[VS]1002搭桥
- spring Boot报错 之五种(不打包运行)
- dos 上版
- css处理文本内容过多.....显示问题
- 通过FastJson把字符串转换成JSON和Map和List对象处理json数据
- 剑指offer:和为S的两个数字
- SpringBoot之JPA(J)
- ORA-01012: not logged 未完全关闭数据库导致ORA-01012: not logged的解决
- leetcode 216. Combination Sum III
- HDU 6143 Killer Names (容斥/第二类Stirling数)