소프트웨어/Spring Boot

[Spring Boot] init project

개발자_이훈규 2016. 7. 5. 11:38

1. init project


1) 도움말을 보는 것은 spring help [command]이다.


ex) init manual

$ spring help init


spring init - Initialize a new project using Spring Initializr (start.spring.io)


usage: spring init [options] [location]


Option              Description                            

------              -----------                            

-a, --artifactId    Project coordinates; infer archive     

                      name (for example 'test')            

-b, --boot-version  Spring Boot version (for example       

                      '1.2.0.RELEASE')                     

--build             Build system to use (for example       

                      'maven' or 'gradle') (default: maven)

-d, --dependencies  Comma-separated list of dependency     

                      identifiers to include in the        

                      generated project                    

--description       Project description                    

-f, --force         Force overwrite of existing files      

--format            Format of the generated content (for   

                      example 'build' for a build file,    

                      'project' for a project archive)     

                      (default: project)                   

-g, --groupId       Project coordinates (for example 'org. 

                      test')                               

-j, --java-version  Language level (for example '1.8')     

-l, --language      Programming language  (for example     

                      'java')                              

-n, --name          Project name; infer application name   

-p, --packaging     Project packaging (for example 'jar')  

--package-name      Package name                           

-t, --type          Project type. Not normally needed if   

                      you use --build and/or --format.     

                      Check the capabilities of the        

                      service (--list) for more details    

--target            URL of the service to use (default:    

                      https://start.spring.io)             

-v, --version       Project version (for example '0.0.1-   

                      SNAPSHOT')                           

-x, --extract       Extract the project archive. Inferred  

                      if a location is specified without   

                      an extension                         


examples:


    To list all the capabilities of the service:

        $ spring init --list


    To creates a default project:

        $ spring init


    To create a web my-app.zip:

        $ spring init -d=web my-app.zip


    To create a web/data-jpa gradle project unpacked:

        $ spring init -d=web,jpa --build=gradle my-dir


$ spring init --build=gradle [project name]


2) Create init project


$ spring init --build=gradle mydir

Using service at https://start.spring.io

Project extracted to '/home/hklee/test/test2/mydir'


$ ls

mydir


$ tree

.

└── mydir

    ├── build.gradle

    ├── gradle

    │   └── wrapper

    │       ├── gradle-wrapper.jar

    │       └── gradle-wrapper.properties

    ├── gradlew

    ├── gradlew.bat

    └── src

        ├── main

        │   ├── java

        │   │   └── com

        │   │       └── example

        │   │           └── DemoApplication.java

        │   └── resources

        │       └── application.properties

        └── test

            └── java

                └── com

                    └── example

                        └── DemoApplicationTests.java


13 directories, 8 files



2. Add File for Running test

test를 위한 샘플 예제를 하나 만든다.

$ vi Example.java


3. Run


따로 gradle을 이용해서 jar을 만들고 실행할 필요가 없다.


$spring run mydir




Reference : http://docs.spring.io/spring-boot/docs/current/reference/html/cli-using-the-cli.html