我的开发工具是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. struts1.x 核心控制器 和 用户自定义控制器扩展类;

    ServletAction继承于HttpServlet,是struts1.x中和核心控制器. 配置于web.xml文件中,指定config属性,该config属性用于指定formBean和action ...

  2. Spring Cloud的小改进(五)

    1.在Eureka中不能看到具体服务的实例信息: 问题点:服务注册到 Eureka 之后,可以看到在 “Status” 显示的服务信息不明确(不知道具体的服务名等信息),如下图所示: 解决方法: 在服 ...

  3. A Model of Saliency-Based Visual Attention for Rapid Scene Analysis

    A Model of Saliency-Based Visual Attention for Rapid Scene Analysis 题目:A Model of Saliency-Based Vis ...

  4. Email接收验证码,以实现登录/注册/修改密码

    要求 1)实现Email形式的注册功能和相应的登录功能:2)实现忘记密码时的密码找回功能:3)存在数据库中的密码不能以明文形式存放,即建议在浏览器端发送请求前,调用js代码对用户的密码做md5加密 分 ...

  5. Node.js server-side javascript cpu占用高

    也不知道微软咋想的,不搞死我们的电脑不罢休 https://developercommunity.visualstudio.com/content/problem/27033/nodejs-serve ...

  6. 【java】:多线程面试题

    经常面试的时候,让写各种乱七八糟的多线程面试题,收集了很多,有些还是挺好玩的. 1.编写程序实现,子线程循环10次,接着主线程循环20次,接着再子线程循环10次,主线程循环20次,如此反复,循环50次 ...

  7. 计算机爱好者协会技术贴markdown第四期

    首先先让爱酱用CSDN自带的数学公式方法来闪瞎大家的钛合金狗眼: 有没有感觉到Markdown的强大!!!!! ## KaTeX数学公式 您可以使用渲染LaTeX数学表达式 [KaTeX](https ...

  8. kvm+webvirtmgr在centos7上的部署

    #!/bin/bash #+++++++++++++++++++++++++++++++++++++++++++++++++++++++安装配置kvm并创建虚拟机+++++++++++++++++++ ...

  9. JAVA 8 主要新特性 ----------------(六)集合Stream API

    一.简介Stream Java8中有两大最为重要的改变.第一个是 Lambda 表达式:另外一 个则是 Stream API(java.util.stream.*).Stream 是 Java8 中处 ...

  10. JavaScript基础视频教程总结(091-100章)

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...