To enable Spring support:
- Make sure that all the necessary IntelliJ IDEA plugins are enabled. These are the Spring Support plugin (for general Spring support) and also a number of other, more specific plugins (Spring Security, Spring Integration, etc.).
- Create a Java module with a Spring facet or add a Spring facet to an existing Java module.
On this page:
- Making sure that the Spring Support and other Spring plugins are enabled
- Creating a module with a Spring facet
- Adding a Spring facet to an existing module
- Open the Settings dialog (e.g. Ctrl+Alt+SCtrl+Alt+SCtrl+Alt+SCtrl+Alt+SCtrl+Alt+SCtrl+Alt+SAlt+F7Ctrl+Alt+SCtrl+Alt+SCommand CommaCommand CommaCommand Comma).
- In the left-hand part of the dialog, under IDE Settings, select Plugins.
- In the right-hand part of the dialog, on the Plugins page, type spring in the search box. As a result, only the plugins whose names and descriptions contain spring are shown in the list of plugins.
- If the check box to the left of Spring Support is not selected, select it. If you are going to use particular Spring frameworks (Spring Security, Spring Integration, etc.), make sure that the check boxes next to their names are also selected.
- Click OK in the Settings dialog.
- If suggested, restart IntelliJ IDEA.
Depending on the situation, you can choose to create a new project with a Java module or to add a Java module to an existing project.
Do one of the following:
If you are going to create a new project:
click Create New Project on the Welcome
select File | New Project.
As a result, the New Project wizard opens.
If you are going to add a module to an existing project:
open the project you want to add a module
select File | New Module.
As a result, the New Module wizard opens.
- If you are going to create a new project: click Create New Project on the Welcome screen or select File | New Project.
- On the first page of the wizard, in the left-hand pane, select Java.
- In the right-hand part of the page, specify the associated settings and click Next. (See the descriptions of the settings for a new project or for an existing project.)
- On the next of the wizard (the Technologies page), select the Spring check box.
In the right-hand part of the page, select the required library option and, if necessary, specify the
associated settings. You can choose to:
Download and use a Spring implementation library.
To do that, select Download.
Now, to view or modify the associated options, click Configure, and in the Downloading Options dialog that opens:
- Select the Spring version that the library should implement.
- Specify the library name.
- Select the library level (global, project, or module).
- Under Files to download, select which of the files you want to download.
- Under Copy downloaded files to, specify the path to the destination folder. If you want to change the default path, click and specify the folder location in the dialog that opens.
Use a Spring library IntelliJ IDEA is already aware of.
To do that, click Use library and select the required library from the list.
If necessary, configure the library settings (for example, change its name). This is done in the Edit Library dialog which you can open by clicking Configure.
The contents of the Use library list may be different depending on the situation:
- If your are creating a new project, this list contains the Spring libraries already defined in IntelliJ IDEA as global libraries.
- If your are adding a new module to an existing project, this list, in addition, contains the project-level Spring libraries of the current project.
Create a new library using the appropriate JAR files available on your computer.
To do that, click Use library and then click Create. Select the required JAR files in the dialog that opens. (Keep the Ctrl key pressed to perform multiple selection.)
If necessary, configure the new library (for example, change its name or level). To do that, click Configure and specify the required settings in the Create Library dialog.
- Postpone setting up the library until a later time. If this is your intention, select Set up library later.
- Download and use a Spring implementation library.
- If you want to enable support for more specific Spring features or frameworks (for example, Spring Security, Spring Integration, etc.), select the corresponding check boxes and specify the associated library options. The procedure is similar to that for the Spring library.
- Open the module settings.
- With the desired module selected, click on the toolbar, and, under Framework, select Spring.
- Now, to download a Spring implementation library and add it to module dependencies, in the lower part of the Facet 'Spring' page that opens in the right-hand part of the Project Structure dialog, click Fix next to the message reading Spring library not found in the module dependencies list.
- In the dialog that opens, specify the library options as necessary and click OK.
- To add a library for a particular Spring framework (e.g. Spring Security or Spring Integration), click again, and, under Framework, select the framework of interest (e.g. Spring Security).
- In the dialog that opens, specify the necessary library options and click OK.