SpringBoot中遇到的一些问题
JQuery和bootstrap报404的问题
在html页面导入的js和css的时候,不要加static这级目录,直接跳过即可,例如
导入的时候不需要加static目录,直接导入js/和css/即可
后台JAVABean的日期类,前台type=date增加报错的问题
后台错误:
Field error in object ‘user‘ on field ‘birthday‘: rejected value [2013-06-24]; codes [typeMismatch.user.birthday,typeMismatch.birthday,typeMismatch.java.util.Date,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [user.birthday,birthday]; arguments []; default message [birthday]]; default message [Failed to convert property value of type ‘java.lang.String‘ to required type ‘java.util.Date‘ for property ‘birthday‘; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type java.lang.String to type java.util.Date for value ‘2013-06-24‘; nested exception is java.lang.IllegalArgumentException]
解决办法
在对应的实体类属性上加入 @DateTimeFormat(pattern = "yyyy-MM-dd")
前台表单Action访问后台Controller,后台跳转html要用重定向
这里直接用return "html地址" 是不行的
return "redirect:/index";
要用重定向。
设置SpringBoot访问localhost:8080的默认跳转页面
这个在SpringMVC中很好设置直接在Web.xml写的东西在SpringBoot里面变得有些麻烦
这里要写一个配置类,在配置类里写入你想跳转的默认访问页面
代码如下
@Configuration
public class DefaultView extends WebMvcConfigurerAdapter {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("forward:/index"); //在这里写上要跳转的默认主页
registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
super.addViewControllers(registry);
}
}
数据源配置错误
这里的问题就是我们在创建SpringBoot框架的时候勾选了数据库相关的依赖,但是在启动tocmat过程中并没有配置这个数据库依赖(比如我勾选了但是没有用到数据库,只是测试一下),就会报如下图的错误
解决方法
只能在SpringBootApplication注解中加上下面这行代码,或者添加数据库配置
exclude= {DataSourceAutoConfiguration.class}
该注解的作用是,排除自动注入数据源的配置(取消数据库配置),一般使用在客户端(消费者)服务中
解决org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)问题
接口Dao的接口名与Mapper的文件名一定要一模一样。
最新文章
- C#2.0 特性
- [linux] FastDFS访问文件,400 Bad Request
- GraphicsMagick为图片添加水印
- ng-repeat 遍历同值数组导致的报错
- 关于初学者上传文件到github的方法
- 个人的IDE制作(vim)——适用于C++/C
- 你真的了解mysql的varchar字段的长度有多少吗?
- js获取当前时间戳
- Java基础----jdk1.8 反射实验
- 阿里云负载均衡SLB的文件上传下载问题解决
- 《java.util.concurrent 包源码阅读》25 Fork/Join框架之Fork与Work-Stealing(重写23,24)
- C++标准库vector类型的使用和操作总结
- SpringBoot使用ELK日志收集
- On the Optimal Approach of Survivable Virtual Network Embedding in Virtualized SDN
- DataGuard---->;物理StandBy的角色切换之switchover
- caffe训练模型中断的解决办法(利用solverstate)
- 下一个更大的数 Next Greater Element
- 理解Kubernetes(2): 应用的各种访问方式
- 从QQ音乐开发,探讨如何利用腾讯云SDK在直播中加入视频动画
- Visual Studio 编译信息细度显示设置