Spring 초기 프로젝트 생성

Spring Initializr

Spring Initializr는 조건에 맞게 초기 Spring Boot 프로젝트를 생성하는 웹 서비스이다. 웹 UI에서 프로젝트 설정 및 사용하는 Spring Project를 지정하면 쉽게 Spring Boot 프로젝트 개발을 시작할 수 있다.

curl을 사용한 Spring Initializr

Spring의 검증 등으로 여러 번 프로젝트를 스크랩 또는 빌드하는 경우에는 Web UI에서의 버거롭니다. 따라서 여기에서는 curl을 사용하여 Spring Initializr의 API에 액세스하여 초기 프로젝트를 생성할 수 있다.

% curl https://start.spring.io/
  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
:: Spring Initializr ::  https://start.spring.io

This service generates quickstart projects that can be easily customized.
Possible customizations include a project's dependencies, Java version, and
build system or build structure. See below for further details.

The services uses a HAL based hypermedia format to expose a set of resources
to interact with. If you access this root resource requesting application/json
as media type the response will contain the following links:
+-----------------+------------------------------------------+
| Rel             | Description                              |
+-----------------+------------------------------------------+
| gradle-build    | Generate a Gradle build file.            |
| gradle-project  | Generate a Gradle based project archive. |
| maven-build     | Generate a Maven pom.xml.                |
| maven-project * | Generate a Maven based project archive. |
+-----------------+------------------------------------------+


The URI templates take a set of parameters to customize the result of a request
to the linked resource.
+-----------------+------------------------------------------+------------------------------+
| Parameter       | Description                              | Default value                |
+-----------------+------------------------------------------+------------------------------+
| applicationName | application name                         | DemoApplication              |
| artifactId      | project coordinates (infer archive name) | demo                         |
| baseDir         | base directory to create in the archive  | no base dir                  |
| bootVersion     | spring boot version                      | 2.7.2                        |
| dependencies    | dependency identifiers (comma-separated) | none                         |
| description     | project description                      | Demo project for Spring Boot |
| groupId         | project coordinates                      | com.example                  |
| javaVersion     | language level                           | 17                           |
| language        | programming language                     | java                         |
| name            | project name (infer application name)    | demo                         |
| packageName     | root package                             | com.example.demo             |
| packaging       | project packaging                        | jar                          |
| type            | project type                             | maven-project                |
| version         | project version                          | 0.0.1-SNAPSHOT               |
+-----------------+------------------------------------------+------------------------------+

... 생략 ...

Examples:

To create a default demo.zip:
	$ curl -G https://start.spring.io/starter.zip -o demo.zip

To create a web project using Java 11:
	$ curl -G https://start.spring.io/starter.zip -d dependencies=web \
			-d javaVersion=11 -o demo.zip

To create a web/data-jpa gradle project unpacked:
	$ curl -G https://start.spring.io/starter.tgz -d dependencies=web,data-jpa \
		   -d type=gradle-project -d baseDir=my-dir | tar -xzvf -

To generate a Maven POM with war packaging:
	$ curl -G https://start.spring.io/pom.xml -d packaging=war -o pom.xml



최종 수정 : 2024-04-23