Spring file templates
File templates are reusable blueprints that define the default structure and initial content for files you create in your project. For Spring, IntelliJ IDEA provides file templates for component files and XML configuration files.
Use Spring component file templates
Right-click a directory under main/java or main/kotlin and select New (or press Alt+Insert).
Select Spring Java Component (for Java projects) or Spring Kotlin Component (for Kotlin projects).
Select a type of the component, such as a Controller for a
@RestController
class or Application for a@SpringBootApplication
class.Controller, RestController, and Controller Advice templates are available if the project has the
spring-web
dependency. The Repository template is available if the project has thespring-data-commons
dependency.
The created file will include the package name and all the necessary imports and annotations.
Spring component file templates are also available in the Generate action. With your class source code opened in the editor, press Alt+Insert and select Spring Component.

Use Spring XML configuration file templates
Right-click the resources directory and select New (or press Alt+Insert).
Select
.Enter a name for your configuration file.
In projects prior to Spring 2.0, this will create DTD-based XML files. In Spring 2.0 and later, this will create Schema (XSD)-based XML files.
Customize Spring file templates
In the Settings dialog (Ctrl+Alt+S) , go to .
Open the Other tab, expand the Spring category, and customize the templates.
By default, file templates are created at the IDE level: template modifications are available in all projects that you open with the current IDE instance. For more information about template scopes and sharing templates, refer to Share file templates.