DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • How Spring and Hibernate Simplify Web and Database Management
  • Functional Endpoints: Alternative to Controllers in WebFlux
  • Graceful Shutdown: Spring Framework vs Golang Web Services
  • Actuator Enhancements: Spring Framework 6.2 and Spring Boot 3.4

Trending

  • Manual Sharding in PostgreSQL: A Step-by-Step Implementation Guide
  • The Smart Way to Talk to Your Database: Why Hybrid API + NL2SQL Wins
  • Can You Run a MariaDB Cluster on a $150 Kubernetes Lab? I Gave It a Shot
  • AI Speaks for the World... But Whose Humanity Does It Learn From?
  1. DZone
  2. Coding
  3. Frameworks
  4. Spring Sweets: Running Our Own Spring Initializr Server

Spring Sweets: Running Our Own Spring Initializr Server

The author walks us through step-by-step to run Spring Initializr.

By 
Hubert Klein Ikkink user avatar
Hubert Klein Ikkink
·
Jun. 19, 16 · Tutorial
Likes (1)
Comment
Save
Tweet
Share
10.4K Views

Join the DZone community and get the full member experience.

Join For Free

To start a new project based on Spring or Spring Boot we can use the website start.spring.io. We can easily create a project template based on Maven or Gradle and define all needed dependencies by clicking on checkboxes in the UI. In a previous post we also learned how to create a project using a URL using the same start.spring.io website. The start.spring.io website is actually a Spring Boot application and we can easily host our own server. With our own server we can, for example, limit the number of dependencies, force Gradle as the only build tool, and set default values for project name, packages, and much more.

To get started we must first clone the GitHub project. We need to build the project with Maven to install the libraries in our local Maven repository. After that is done we are reading to use it in our own Spring Boot application that is our customized Spring Initializr server. The easiest way to run the server is to have the Spring CLI tool installed. The easiest way to install it is using SDKMAN!. We type  $ sdk install springboot on the command line.

Next we create a new directory and inside the directory we create a new Groovy file initializr.groovy:

view sourceprint?

package app

@Grab('io.spring.initalizr:initializr-web:1.0.0.BUILD-SNAPSHOT')
@Grab('spring-boot-starter-web')
class InitializerService {}

Next we need a configuration file with all the options for the Spring Initializr server. We can start by copying the file application.yml from theinitializr-service project on GitHub to our directory with the file initializr.groovy. This file contains a lot of information. The configuration format is explained on the GitHub wiki, but it is really straight forward. If we open the file we can, for example, remove dependencies from the dependencies or set default values for the groupId. If we only want to support Gradle we can remove the Maven references from the types section. And of course to have Groovy as the default language we can in the languages section set the default to true for Groovy.

...
  artifactId:
    value: sample
  groupId:
    value: com.mrhaki
  version:
    value: 1.0.0.DEVELOPMENT
  name:
    value: Sample
  description:
    value: Sample Project
  packageName:
    value: com.mrhaki.demo
...
  types:
    - name: Gradle Project
      id: gradle-project
      description: Generate a Gradle based project archive
      sts-id: gradle.zip
      tags:
        build: gradle
        format: project
      default: false
      action: /starter.zip
    - name: Gradle Config
      id: gradle-build
      description: Generate a Gradle build file
      sts-id: build.gradle
      tags:
        build: gradle
        format: build
      default: true
      action: /build.gradle
...
  javaVersions:
    - id: 1.8
      default: true
  languages:
    - name: Java
      id: java
      default: false
    - name: Groovy
      id: groovy
      default: true
...

And that is it! We are ready to start our own Spring Initializr server:

$ spring run initializr.groovy

...

For a finishing touch we can also override the static resources and templates of the server application. For example we can add a new spring.css file in the directory static/css. And place a file home.html in the directory templates. We can take the existing files as a sample and change what we want.

The following screenshot shows a customized template with some style changes:

We can even use our server to create a project from IntelliJ IDEA. When we create a new project and select Spring Initializr from the list box on the left we can type in the URL of our server:

Next we see our default values for the project details:

And finally we can select the dependencies we have defined in our application.yml file:

Spring Framework

Published at DZone with permission of Hubert Klein Ikkink, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • How Spring and Hibernate Simplify Web and Database Management
  • Functional Endpoints: Alternative to Controllers in WebFlux
  • Graceful Shutdown: Spring Framework vs Golang Web Services
  • Actuator Enhancements: Spring Framework 6.2 and Spring Boot 3.4

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!