Spring Initializr: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(41 intermediate revisions by the same user not shown)
Line 1: Line 1:
=External=
=External=


* https://start.spring.io/
* Spring Initializr Reference Guide https://docs.spring.io/initializr/docs/current-SNAPSHOT/reference/htmlsingle/
* Spring Initializr Reference Guide https://docs.spring.io/initializr/docs/current-SNAPSHOT/reference/htmlsingle/
* Spring Initializr GitHub https://github.com/spring-io/initializr/
* Spring Initializr GitHub https://github.com/spring-io/initializr/
* https://start.spring.io/


=Internal=
=Internal=
Line 11: Line 11:
=Overview=
=Overview=


'''Spring Initializr''' is a REST API that generates [[Spring Boot]] projects, allowing you to customize the build system and the project coordinates, the language and version, the packaging and the dependencies to add to the project. The API can be exposed as a service, and the publicly available default instance for the service, run by Pivotal, is available at https://start.spring.io/.
Spring Initializr is a REST API that generates a skeleton Spring project structure, allowing you to customize the build system ([[Maven]] or [[Gradle]]), the project coordinates, the language and version, the packaging and the dependencies to add to the project. The API can be exposed as a service, and the publicly available default instance for the service, run by Pivotal, is available at https://start.spring.io/.
 
The API can be used standalone or embedded in other tools:
* With a browser by going to http://start.spring.io
* From command-line with [[curl]]
* From command-line using [[Spring Boot CLI]]
* From IntelliJ IDEA, with  [[IntelliJ IDEA Plugin for Spring Boot]]
* From Spring Tool Suite
* From NetBeans
 
All these tools work by invoking into http://start.spring.io and downloading the project ZIP, which is subsequently expanded in the local workspace.
 
=Spring Project Structure=
For both Maven and Gradle-based projects, the source code is placed under:
<font size=-1>
src/main/java/..../appname
                      ├─ controller
                      ├─ repository # repository interfaces
                      ├─ data # data model
                      └─ stream # Spring Cloud Stream
</font>
The [[Spring_Boot_Concepts#Spring_Boot_Main_Class|Spring Boot main class]], which bootstraps the project, lives under this directory.
 
The test code is placed under:
<font size=-1>
src/test/java
</font>
Spring Initializr will add at least one test class that ensures that the Spring [[Spring_Dependency_Injection_and_Inversion_of_Control_Container_Concepts#Application_Context|application context]] loads successfully.
 
The non-Java project resources are placed under:
<font size=-1>
src/main/resources
</font>
An empty [[Spring Property Injection Concepts#application.properties|application.properties]] file is created and placed under <code>resources</code>. If the application has web dependencies, the <code>resources/static</code> and <code>resources/templates</code> subdirectories are also created. Maven (<code>mvnw</code>, <code>mvnw.cmd</code>) or Gradle (<code>gradlew</code>, <code>gradlew.bat</code>) wrapper scripts are also created, they can be used to build the project even if Maven or Gradle is not installed in the local development environment. More details about [[Gradle_Concepts#The_Gradle_Wrapper|Graddle wrapper scripts]].<span id='Build_Specification'></span> For Maven-based project, Spring Initializr generates the Maven build specification: {{Internal|Spring_Initializr_pom.xml|pom.xml}}
For Gradle-based project, Spring Initializr generates the Gradle build specification as a pair of two files: {{Internal|Spring_Initializr_build.gradle|build.gradle}}{{Internal|Spring_Initializr_settings.gradle|settings.gradle}}
 
These contain the dependencies specified on execution, plus a few default ones, like testing support.


The API can be used standalone or embedded in other tools, notably the IntelliJ IDEA plugin for Spring Boot.
=Procedures=


=Subjects=
==Create a New Spring Boot Project with Spring Initializr from IntelliJ==


* [[Spring Initializr Concepts]]
{{Internal|IntelliJ_IDEA_Plugin_for_Spring_Boot#Create_a_New_Spring_Boot_Project_with_Spring_Initializr|Create a New Spring Boot Project with Spring Initializr from IntelliJ}}

Latest revision as of 23:54, 6 February 2022

External

Internal

Overview

Spring Initializr is a REST API that generates a skeleton Spring project structure, allowing you to customize the build system (Maven or Gradle), the project coordinates, the language and version, the packaging and the dependencies to add to the project. The API can be exposed as a service, and the publicly available default instance for the service, run by Pivotal, is available at https://start.spring.io/.

The API can be used standalone or embedded in other tools:

All these tools work by invoking into http://start.spring.io and downloading the project ZIP, which is subsequently expanded in the local workspace.

Spring Project Structure

For both Maven and Gradle-based projects, the source code is placed under:

src/main/java/..../appname
                      ├─ controller
                      ├─ repository # repository interfaces
                      ├─ data # data model
                      └─ stream # Spring Cloud Stream

The Spring Boot main class, which bootstraps the project, lives under this directory.

The test code is placed under:

src/test/java

Spring Initializr will add at least one test class that ensures that the Spring application context loads successfully.

The non-Java project resources are placed under:

src/main/resources

An empty application.properties file is created and placed under resources. If the application has web dependencies, the resources/static and resources/templates subdirectories are also created. Maven (mvnw, mvnw.cmd) or Gradle (gradlew, gradlew.bat) wrapper scripts are also created, they can be used to build the project even if Maven or Gradle is not installed in the local development environment. More details about Graddle wrapper scripts. For Maven-based project, Spring Initializr generates the Maven build specification:

pom.xml

For Gradle-based project, Spring Initializr generates the Gradle build specification as a pair of two files:

build.gradle
settings.gradle

These contain the dependencies specified on execution, plus a few default ones, like testing support.

Procedures

Create a New Spring Boot Project with Spring Initializr from IntelliJ

Create a New Spring Boot Project with Spring Initializr from IntelliJ