Spring configuration files contain bean definitions and other information. They are used to provide context information to the Spring framework.
IntelliJ IDEA lets you manage "traditional" XML configuration files and also @Configuration-annotated Java classes.
Mutually-related configuration files can be arranged in file sets to make their editing more effective.
When working with the configuration files in the editor, you can generate beans, properties, dependencies, etc. using the IntelliJ IDEA's code generation feature ( or or or or ). You can also analyze the structure of your application using the Spring dependencies diagram.or
- Creating a new XML configuration file
- Adding an XML configuration file to a file set
- Creating a @Configuration-annotated Java class
In the Project tool window, select the package or directory
in which you want to create a configuration file.
Then choose File | New or press or or or or .
Alternatively, right-click the package or directory, and click New.
- Select XML Configuration File and then select Spring Config. Note that, as an alternative, you can also select to create a more specific type of Spring configuration file (e.g. Spring Security).
In the New File dialog, specify the name of the configuration file and click OK.
As a result, the new configuration file is created and opened in the editor.
- If necessary, add the configuration file to a file set.
Unless an XML configuration file is included in at least one file set, the Configure File Set link is available in the editor for the configuration file. This link is located above the editing area, in the upper-right corner of the corresponding editor tab.
You can use this link to add the configuration file to a file set:
- Click the Configure File Set link.
If you haven't defined any XML file sets yet,
the Edit Application Context dialog opens.
Configure the file set as required and click OK.
If at least one XML file set already exists, you can add the configuration file to an existing file set or create a new file set and add the configuration file to it. To do that, select the necessary option from the Choose file set menu:
- To add the configuration file to an existing file set, select the necessary file set.
- To add the configuration file to a file set that does not yet exist, select <new file set>. Then, in the Edit Application Context dialog, configure the file set and click OK.
The procedure for creating @Configuration-annotated Java classes is the same as for creating "ordinary" classes, see Creating Java Classes, Interfaces, Enumerations and Annotations.