IntelliJ IDEA 13.1.0 Web Help

Some features described here are available in Ultimate edition only.

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 (Code | Generate or Alt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+InsertCtrl+N or Alt+InsertAlt+InsertAlt+InsertCommand N or Control EnterControl N or Control EnterCommand N or Control Enter). You can also analyze the structure of your application using the Spring dependencies diagram.

To create a new XML configuration file
  1. 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 Alt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+Insert or Ctrl+NAlt+InsertCommand N or Control EnterControl N or Control EnterCommand N or Control Enter.

    Alternatively, right-click the package or directory, and click New.

  2. 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).
  3. 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.

  4. If necessary, add the configuration file to a file set.
To add an XML 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:

  1. Click the Configure File Set link.
  2. 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.

Note

There is an alternative way of adding a configuration file to a file set. You can do that by editing a file set. See also, Creating a file set.

To create a @Configuration-annotated Java class

The procedure for creating @Configuration-annotated Java classes is the same as for creating "ordinary" classes, see Creating Java Classes, Interfaces, Enumerations and Annotations.

See Also

Language and Framework-Specific Guidelines:

Reference:

Web Resources: