Skip to content

Add Spring Boot Starters to Projects

Martin Lippert edited this page Aug 26, 2020 · 5 revisions

Creating new Spring Boot projects is super easy due to the options that you get from https://start.spring.io (and the corresponding wizards in the IDEs). You select the starter modules - and go. To enable a comparable experience for working with existing projects, the Spring Tools 4 for Eclipse include a specialized wizard to add new starters to existing Spring Boot projects.

Add Spring Boot Starters to an existing project (new in 4.7.2)

When selecting a Spring Boot project or the corresponding included build files, the content-menu offers an action via Spring -> Add Starters.

Once selected, the wizard opens with a very similar selection UI than the wizard to create new projects. All the awesome Spring Boot starter modules from https://start.spring.io/ show up there. Compared to the experience when creating new projects, this wizard offers less choice, of course. You can't select the Java or Boot version, the packaging type, etc. All those settings are already on the project itself. Instead, the wizard pre-selects the Spring Boot version that the project is working with an offers a choice of starters that work with that version of Spring Boot.

The wizard does not analyze which starters the project might already use and tries to be smart about that to offer less choice or anything like that in the UI. You get the full list of starter modules in the UI, independent of the starters that are already included in the project. You can just go ahead and select the starters you would like to add to the project.

Once you selected the starter modules you would like to add, press Continue to see what would happen to your project. On the next page of the wizard, you will get a detailed view of what the service at https://start.spring.io would generate if you select those starters and compares that with what you already have on your project.

/images/add-startes-second-page.png

The first section of the wizard shows you the files that you might not already have on your project or files that files that already exist in your project, but the new starter modules would modify and add content to them.

New files and resources

Your selection of starter modules might, for example, cause the creation of a new empty folder structure like src/main/resources or the creation of a new .gitignore file. All those files would be automatically created for you if you would create a brand new project on https://start.spring.io. For your existing project, the wizard highlights those files and allows you to get them created in your existing project as well. Just check the file in the list of files.

Existing files and resources

If https://start.spring.io would create a file with some content that already exists in your project, the wizard will highlight those files and allow you to view a diff - to see what is new. This is particularly interesting for the build files, e.g. your pom.xml file. This is probably the file you are most interested in, since this is the central place where the new starter modules end up being defined.

By clicking on the file in the wizard, you can open a detailed diff view of the file in your project and the file that the starter service would generate. In most of the cases, the new dependencies for the starters you would like to add show up here. You can select all those changes to be applied to your project or select individual changes, if there is something you don't want to include in your project.

As a shortcut, you could also just check the changed file in the above structural comparison and via that action accept all changes for that file. This works nicely for most files, since the wizard is smart enough to not apply changes to your project artifact name, for example. Once you start to use it, you will see that you can just accept all the changes in most of the cases.

Clone this wiki locally