1.springboot整合mybatis mapper注入时显示could not autowire,如果强行写(value = false ),可能会报NullPointException异常
解决方案:
dao层加注解@Component(value = "首字母小写的接口名如UserMapper->userMapper")
dao层还可以加注解@Mapper
2.The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone问题
3.java.lang.IllegalArgumentException: DefaultSerializer requires a Serializable payload but received an object of type[xxx]
解决:实体对象类没有序列化,需要implements Serializable
4.SpringBoot JPA 中无法注入 JpaRepository 接口的问题及解决方案
方案一、把 @SpringBootApplication 注解的 SpringBoot 入口类移到上层 root 包中,使 JpaRepository 子接口位于 root 包及其子包中。
方案二、在 SpringBoot 入口类上添加
(1) @ComponentScan(basePackages = "xxx.xxx.xxx"):扫描 @Controller、@Service 注解;
(2) @EnableJpaRepositories(basePackages = "xxx.xxx.xxx"):扫描 @Repository 注解;
(3) @EntityScan(basePackages = "xxx.xxx.xxx"):扫描 @Entity 注解;
实测方案二的第一个注解有效
5.An error happened during template parsing (template: "class path resource [templates/user/list.html]" - line ...)
因为User的属性都是私有的,所以thymeleaf使用的时候需要用getXXX方法:
6.关于thymeleaf中红色波浪线的问题解决
三种解决方案:
a.
取消勾选
b.对波浪线出alt+enter,选择注释
我试了,没成功
c.在<!DOCTYPE html>下加上 <!--suppress ALL--> 确实有效,但不知原因
综上,采用第一种
7.JPA实体对应表名
注意驼峰命名规则,倘若不是,JPA会自动新建一列表
@Id
@GeneratedValue
private Long id;
@Column(nullable = false,unique = true)
private String userName;
@Column(nullable = false)
private String password;
@Column(nullable = false)
private int age;
如其中的userName,需要在设计数据库表时将column设置为user_name;
不创建表也可以,JPA会帮我们创建表 = =
顺便复习下mysql知识:
查看列:desc 表名;
修改表名:alter table t_book rename to bbb;
添加列:alter table 表名 add column 列名 varchar(30);
删除列:alter table 表名 drop column 列名;
修改列名MySQL: alter table bbb change nnnnn hh int;
修改列名SQLServer:exec sp_rename't_student.name','nn','column';
修改列名Oracle:lter table bbb rename column nnnnn to hh int;
修改列属性:alter table t_book modify name varchar(22);