H2数据库
检查确认创建了 该表,但是还是 not find table
可能是连错数据库了,重新连接一下子,,看看配置路径对不对
默认账号:密码是 sa :123
H2数据库只支持单链接
[ERROR] SQL State : 90020
[ERROR] Error Code : 90020
[ERROR] Message : Database may be already in use: null. Possible solutions: close all other connection(s); use the server mode [90020-199]: The
file is locked: nio:C:/Users/hwj/community-my.mv.db [1.4.199/7]
Intellij IDEA
Intellij IDEA 中文无法输入及中英文没法自由切换
1、关掉idea后在idea的安装路径下把jre64文件夹删掉,或者重命名也行,如把jre64改成jre642
2、升级jdk版本至jdk 8u45以上
3、把Java安装路径下的jre文件拷贝到IDEA的安装目录下并重命名为jre64;
4、把对应版本的jdk/lib的tools.jar拷贝到jre64/lib下;
搞定,再次启动idea即可。
原文链接:https://blog.youkuaiyun.com/kk123k/article/details/78233440
Lombok
用了可以少写很多代码,自动set和get方法等
-
用IDEA的首先要安装插件
离线或者在线安装 lombok插件
注意一定要选择和你的IDEA对应版本的插件,否则安装不上
推荐github下载(比较全),IDEA官网似乎有几个版本断了(有的没有)
- maven方式
To include lombok as a ‘provided’ dependency, add it to your <dependencies>
block like so:
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.10</version>
<scope>provided</scope>
</dependency>
</dependencies>
引入依赖
mybatis
开启驼峰
@Mapper
public interface QuestionMapper {
@Insert("insert into question (title,description,gmt_create,gmt_modified,creator,tag) values (#{title},#{description},#{gmtCreate},#{gmtModified},#{creator},#{tag})")
void create(Question question);
@Select("select * from question")
List<Question> list();
}
public class Question {
private Integer id;
private String title;
private String description;
private String tag ;
private Long gmtCreate;
private Long gmtModified;
private Integer creator;
private Integer viewCount;
private Integer commentCount;
private Integer likeCount;
}
以上情况
去application.properties里配置开启(默认关闭)
mybatis.configuration.map-underscore-to-camel-case=true
Spring devtoos
当项目被修改,自动重启
有两种自动部署,这里用免费的,它实际上是有两个 classLoader,当有修改时,开启新的,关闭旧的,比手动重启要快。
对应静态的样式修改,不会重启服务(可以设置重启)
另一种是收费的,它是替换字节码的方式,这种速度更快
使用步骤
-
项目里引入依赖
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency> </dependencies>
对于eclipse添加依赖,勾选自动构建选项
基于IDEA需要做如下设置更加好用(否则必须每次手动 构建 Building project)
-
setting里设置勾选上 Build project automatically
-
ctrl + shift + alt + ?
选择 Registry
- 勾选compiler.automake.allow.when.app.running
如何删除cookie和session
@GetMapping("/logout")
public String logout(HttpServletRequest request,HttpServletResponse response){
//删除session
request.getSession().removeAttribute("user");
//删除cookie
Cookie cookie = new Cookie("token",null);
cookie.setMaxAge(0);
response.addCookie(cookie);
return "redirect:/";
}