Spicy Spring: Create New Projects From a URL

To quickly start with a Spring project we can use the website start.spring.io. Via a user interface we can set project properties and at the end we have a project archive (Zip or gzipped Tar file) or build file (pom.xml or build.gradle). We can also directory access an URL to create the output files and we set the properties via request parameters. This way you can share a link with someone and if they click on it they will download the generated project archive or build files.

We can choose different base URLs depending on the type of project archive we want. To get a Zip file we use http://start.spring.io/starter.zip and to get a gzipped Tar file we use http://start.spring.io/starter.tgz. To create a Gradle build file with all the configuration for a project we use http://start.spring.io/build.gradle. For a Maven POM XML file we use the URL hhttp://start.spring.io/pom.xml.

All output format support the same request parameters to set the project properties:

Request parameter Description Sample
dependencies Add Spring Boot Starters and dependencies to your application web,security
style Alias for dependencies actuator,sleuth,eureka&20discovery
type Used for project archives. Use gradle-project or maven-project gradle-project
name Name of project demo
description Description for the project Demo%20project%20for%20Spring%20Boot
groupId Value for groupId for publishing project com.example
artifactId Value for artifactId for publishing project demo
version Version of the project 1.0.0.DEVELOPMENT
bootVersion Version for Spring Boot 1.3.3
packaging Packaging for project (jar or war) jar
applicationName Name of the application demo
language Language can be Java, Groovy or Kotlin Groovy
packageName Name for package for example code com.example
javaVersion Java version for project 1.8
baseDir Base directory in archive sample

Let’s create a URL for a Groovy project with a Gradle build file where we have a dependency on web, security and actuator:

When we save the Gradle build file we have the following file contents:

Instead of just a build file we want to create a sample project archive file. We use the following URL:

Let’s open the archive and see the contents. Notice we used the baseDir request parameter so when we unpack we get a new directory.

Written with Spring Boot 1.3.3.

Original blog post

This entry was posted in Coding and tagged , , , , by mrhaki. Bookmark the permalink.

About mrhaki

My name is Hubert A. Klein Ikkink also known as mrhaki. I work at the great IT company JDriven. Here I work on projects with Groovy & Grails, Gradle and Spring. At JDriven we focus on SpringSource technologies. All colleagues want to learn new technologies, support craftmanship and are very eager to learn. This is truly a great environment to work in. You can contact me via Google+ or @mrhaki.

Leave a Reply

Your email address will not be published. Required fields are marked *