Skip to content

Validations And Quick Fixes

Martin Lippert edited this page Dec 9, 2022 · 2 revisions

Spring-Specific Validations (experimental, new in 4.17.0 / 1.41.0)

The new version of the Spring Tools 4.17.0 (and the corresponding extensions for VSCode in version 1.41.0) introduces experimental support for a number of Spring specific validations and corresponding quick fixes.

Examples for those validations are:

  • field injections (using @Autowired on a field) where constructor parameters should be used instead
  • useless @Autowired annotations on constructors that could be removed
  • the usage of @RequestMapping where specific mapping annotations like @GetMapping should be used instead

Please take a look at the preferences to see the full list of validations that the tools provide.

Customize which validations you would like to see

Since the validations are often related to specific styles or recommendations how to use Spring, they do not necessarily point to real problems or errors. Therefore, you can define the severity of each of these validations individually in the preferences. You can change those preferences to choose the right level for your case - or turn every validation to IGNORE if you don't want to see any those validations to appear.

Experimental nature of this new feature and potential side effects

The tooling uses a new library and an experimental new architecture as a foundation for the new validations and quick fixes, which is based on OpenRewrite. To enable the validations and quick fixes, users need to enable Reconciling for Java sources in the preferences. In addition to that a prompt asks users for this preference once (for awareness).

Potential side effects of this new experimental foundation can include a much increased memory consumption inside of the language server process that runs side-by-side with your coding environment. If you observe anything like that, you can disable the Reconciling for Java sources in the preferences again to see if that solves the issue. In addition to that it would be great to report those situations via https://github.com/spring-projects/sts4/issues, and maybe attach a heap dump (if possible), so that we can analyze those situations in more detail.

Clone this wiki locally