- 设置类的注释格式
- 进入Settings界面
Editor
->File and Code Templates
->File Header
,右侧输入注释模板
设置类的注释格式 - 代码片段
- 进入Settings界面
/**
* @author ${USER}
* @since ${DATE} ${TIME}
*/
- 设置Entity模板
-
进入Settings界面
创建entityEditor
->File and Code Templates
->Files
,下侧点击加号按钮创建新模板
-
代码片段
-
package ${PACKAGE_NAME};
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import javax.persistence.*;
import java.util.Date;
#parse("File Header.java")
@Entity
public class ${NAME} {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@JsonIgnore
private Integer id;
@Column(updatable = false)
@CreationTimestamp
## @JsonFormat(pattern = "yyyy-MM-dd HH:mm:SS", timezone = "GMT+8")
@JsonIgnore
private Date createtime;
@UpdateTimestamp
@JsonIgnore
private Date updatetime;
}
- RepositoryInterface模板
-
操作步骤同上,newClass的时候输入Entity名称
RepositoryInterface -
代码:
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
import com.weiresearch.entity.${NAME};
import org.springframework.data.jpa.repository.JpaRepository;
#parse("File Header.java")
/**
* @author ${USER}
*/
public interface ${NAME}Repository extends JpaRepository<${NAME},Integer>{}
网友评论