How IntelliJ IDEA File Templates made my life easier as a developer.

Keep in mind, that you can use these instructions on other JetBrains IDE’s
“WebStorm, PyCharm, RubyMine etc.”

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Entity
public class MyAwesomeEntity {

@Id
@GeneratedValue
@Column(length = 36, columnDefinition = "varchar(36)", updatable = false, nullable = false)
@Type(type = "org.hibernate.type.UUIDCharType")
private UUID id;

@CreationTimestamp
@Column(updatable = false)
private Timestamp createdDate;
@UpdateTimestamp
private Timestamp lastModifiedDate;

}

Now, to stop reproducing this code from scratch over and over again we can just press :
- Double SHIFT (Search everywhere)
- Search: “Save File as template”
- Give it the name “MyAwesomeEntity”
And then hit
OK

Double “Shift” in IntelliJ IDEA
Creating a File Template

Here’s how we use the file template:
- Open Project tool Window
(Mac -> cmd+1 or Windows -> alt+1)
- Right click on the package that you want to create the entity
- Choose Java Class
- Give it a name “MyAwesomeEntityReused”
-
Choose the template “MyAwesomeEntity”
- Press
Enter

Using a File Template

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store