我的开发工具是IntelliJ IDEA,然后在SpringBoot集成Mybatis,前端用模块引擎Thymeleaf的过程中遇到几个问题,不过也花了点时间,现在记录下来,作为笔记记录。

Invalid bound statement异常

开发中经常遇到,下面给出我的两种方法

Invalid bound statement (not found):

①Mapepr.xml文件中文nameapce没有和mapper接口发生映射

②有可能是在IDEA编辑器运行的项目,需要project structure设置mybatis的xml文件夹为resource

Thymeleaf前端显示时间格式不规范

解决方案是写个配置类

package com.muses.taoshop.manager.config;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistrar;
import org.springframework.format.FormatterRegistry;
import org.springframework.format.datetime.DateFormatter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale; /**
* <pre>
* Thymeleaf模板引擎配置
* </pre>
*
* @author nicky
* @version 1.00.00
* <pre>
* 修改记录
* 修改后版本: 修改人: 修改日期: 2018.09.22 10:50 修改内容:
* </pre>
*/
@Configuration
public class ThymeleafConfig extends WebMvcConfigurerAdapter implements ApplicationContextAware{ @Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { } @Override
public void addFormatters(final FormatterRegistry registry){
super.addFormatters(registry);
registry.addFormatter(dateFormatter());
} @Bean
public DateFormatter dateFormatter(){
return new MyDateFormatter();
} class MyDateFormatter extends DateFormatter {
@Override
public String print(Date date, Locale locale) {
//return super.print(date, locale);
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
}
}
}

获取后台timestamp类型数据,页面得到一串unix long类型数据

获取后台timestamp类型数据,页面得到一串unix long类型数据,解决方案是用fastjson的@JSONField注解可以解决

 @JSONField(format ="yyyy-MM-dd HH:mm:ss")
private Date createTime;

Mybatis+Thymeleaf开发遇到的几个问题笔录的更多相关文章

  1. Spring Boot 2.X(三):使用 Spring MVC + MyBatis + Thymeleaf 开发 web 应用

    前言 Spring MVC 是构建在 Servlet API 上的原生框架,并从一开始就包含在 Spring 框架中.本文主要通过简述 Spring MVC 的架构及分析,并用 Spring Boot ...

  2. Spring boot 整合 Mybatis + Thymeleaf开发web(二)

    上一章我把整个后台的搭建和逻辑给写出来了,也贴的相应的代码,这章节就来看看怎么使用Thymeleaf模板引擎吧,Spring Boot默认推荐Thymeleaf模板,之前是用jsp来作为视图层的渲染, ...

  3. SpringMVC,Spring,Hibernate,Mybatis架构开发搭建之SpringMVC部分

    SpringMVC,Spring,Hibernate,Mybatis架构开发搭建之SpringMVC部分 辞职待业青年就是有很多时间来写博客,以前在传统行业技术强度相对不大,不处理大数据,也不弄高并发 ...

  4. spring boot + Thymeleaf开发web项目

    "Spring boot非常适合Web应用程序开发.您可以轻松创建自包含的HTTP应用.web服务器采用嵌入式Tomcat,或者Jetty等.大多数情况下Web应用程序将使用 spring- ...

  5. SSM 即所谓的 Spring MVC + Spring + MyBatis 整合开发。

    SSM 即所谓的 Spring MVC + Spring + MyBatis 整合开发.是目前企业开发比较流行的架构.代替了之前的SSH(Struts + Spring + Hibernate) 计划 ...

  6. Atitit mybatis快速开发 的sql api接口

    Atitit mybatis快速开发 的sql api接口 1.1. sql模式 开发速度大大快与 映射模式1 1.2. MyBatis Mapper1 1.2.1. 代码2 1.2.2. 原理2 1 ...

  7. Mybatis注解开发模糊查询

    Mybatis注解开发模糊查询 一般在使用mybatis时都是采用xml文件保存sql语句 这篇文章讲一下在使用mybatis的注解开发时,如何进行模糊查询 模糊查询语句写法(在@Select注解中) ...

  8. Springboot 和 Mybatis集成开发

    Springboot 和 Mybatis集成开发 本项目使用的环境: 开发工具:Intellij IDEA 2017.1.3 jdk:1.7.0_79 maven:3.3.9 额外功能 PageHel ...

  9. Springmvc+Spring+Mybatis整合开发(架构搭建)

    Springmvc+Spring+Mybatis整合开发(架构搭建) 0.项目结构 Springmvc:web层 Spring:对象的容器 Mybatis:数据库持久化操作 1.导入所有需要的jar包 ...

随机推荐

  1. java常用集合浅层解析-面试必备

    ArrayList 1.动态数组 2.线程不安全 3.存储空间连续 4.查询快,添加删除慢 构造方法 /** + Shared empty array instance used for defaul ...

  2. Curl测试socks5 or http 代理命令

    测试socks5命令:curl --socks5 125.119.175.48:8909 http://example.com/ 测试http命令: curl --connect-timeout 2 ...

  3. PS教程:大神教你用PS制作《大鱼海棠》海报

        本来做的是一千左右像素的,但最后粗心让我存成500几px的了,可能会有点不清楚,唉,忙活这莫久竟然不敌最后一步的粗心呀     教程有千千万,但跟着作就好像是以前幼儿园老师拿着你的手写字,你可 ...

  4. mysql 报错 Packets larger than max_allowed_packet are not allowed

    登录 mysql, 执行命令 : show variables like '%max_allowed_packet%'  重新设置: set global max_allowed_packet = 1 ...

  5. Ajax使用的五步法

    Ajax使用的五步法 <script type="text/javascript">           //用于保存XMLHttpRequest对象的变量,由于整个过 ...

  6. 重置表单中的文件上传控件(file input)的方法

    方法一: 调用所在 form 表单的 reset 方法,这个方法的缺点是会把整个表单重置,需要存储表单的状态,再回填回去 方法二: 使用jQuery,代码为: $("#id").r ...

  7. linux shell数组赋值方法(常用)

    http://blog.csdn.net/shaobingj126/article/details/7395161 Bash中,数组变量的赋值有两种方法: (1) name = (value1 ... ...

  8. centos6安装oracle时运行./runInstaller无法弹出图形界面

    首先确保安装oracle的机器上安装了图形化界面. 1.利用xmanager登录到安装oracle的服务器上(直接用root用户登录) 2.运行 export DISPLAY=你的本机地址:0.0 3 ...

  9. windows 子系统 linux wsl 开启ssh 服务

    原因 windows自带的终端操作丑陋,习惯xshell的操作 步骤 1.关闭windows自带的ssh服务,这个占用了22端口 2.wsl 安装ssh服务(使用的是ubuntu) sudo apt ...

  10. Unity使用代码动态给按钮赋值各个状态下的图片

    一个小知识点,怕忘记,所以记录下.废话不多说,直接上代码: 未赋值之前: 使用下面代码赋值: using UnityEngine; using UnityEngine.UI; public class ...