简体   繁体   中英

Modify template used in generating `toString` method in Java code editor in IntelliJ

I have seen some documentation such as this and some Stack Overflow questions like this which talk about templates, perhaps Velocity templates, used by IntelliJ when generating a toString method in a Java class.

But no where can I find where this template lives, or how to access it from within IntelliJ.

➥ Exactly how does one find and edit the toString generation templat e in IntelliJ 2018?

Go to Code -> Generate and select toString() from the contextual menu:

在此处输入图片说明

Next, click the Settings button in upper corner.

In the toString() Generation Settings window that appears, select Templates tab.

在此处输入图片说明

Add template:

在此处输入图片说明

Finally, add the Velocity code then click apply:

在此处输入图片说明

Tip: You can duplicate an existing template rather than create an empty one. Click the "double sheets of paper" icon next to the plus and minus icons.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM