Spring Tool Suite configuration associated code inspection template

In some companies with strict code programming standards, there will be configuration templates for public code specifications, formatting, etc., which need to be configured into development tools by themselves, and run checks after coding. How to configure and associate these templates in Spring Tool Suite (Eclipse) ? Record it here.

 

1. Code template file

window-->preferences Search for code templates, click import in the right window, import the template file, and click to see if it takes effect after importing

 


 

 

2. Code formatting templates

window-->preferences Search for formatter, click import in the right window, and import the template file. After importing, the active profile will automatically display the name of the formatted template you imported.

 



 3. Code specification checkstyle template

window-->preferences Search for checkstyle, click the new button in the right window, select external for type, and then select the specific template file. After importing the file, select the file and click set as default.



 

FAQ: After configuration, run checkstyle, report an error, search the Internet, and say that some properties have been removed in the new version of checkstyle, the solution is to remove the content of the error in the check template file you imported

 

Amway, I often encounter errors in eclipse, and the detailed information allows you to see the log, which can be viewed in the .log file under the .metadata folder in the workspace

error message

!MESSAGE Checkstyle-Plugin: cannot initialize module TreeWalker - Unable to instantiate 'RedundantThrows' class, it is also not possible to instantiate it as com.puppycrawl.tools.checkstyle.checks.annotation.RedundantThrows, 

solve

Remove the part that reports the error in the template file

<!--     <module name="RedundantThrows"/> -->

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326646906&siteId=291194637