带有第三方工具的Spring Boot Initilizr

This is continuation to my two previous posts. Before reading this post, please go through my previous posts at “Spring Boot Initilizr Web Interface” , “Spring Boot Initilizr With IDEs or IDE Plugins” and “Spring Boot Initilizr With Spring Boot CLI”.

这是我之前两篇文章的延续。 在阅读本文之前,请仔细阅读我以前的文章:“ Spring Boot Initilizr Web界面 ”, “带有IDE或IDE插件的 Spring Boot Initilizr “带有Spring Boot CLI的Spring Boot Initilizr”

Spring Boot Initilizr is used to quick start new Spring Boot Maven/Gradle projects within no time. It generates initial project structure and build scripts to reduce Development time.

Spring Boot Initilizr用于快速启动新的Spring Boot Maven / Gradle项目。 它生成初始项目结构并构建脚本以减少开发时间。

As we discussed in my previous post, Spring Boot Initilizr is available in the following forms:

正如我们在上一篇文章中讨论的那样,Spring Boot Initilizr具有以下形式:

  1. Spring Boot Initilizr With Web Interface

    具有Web界面的Spring Boot Initilizr
  2. Spring Boot Initilizr With IDEs/IDE Plugins

    具有IDE / IDE插件的Spring Boot Initilizr
  3. Spring Boot Initilizr With Spring Boot CLI

    使用Spring Boot CLI的Spring Boot Initilizr
  4. Spring Boot Initilizr With ThirdParty Tools

    带有第三方工具的Spring Boot Initilizr

Now we are going to discuss on “How to use some popular Third Party Tools to bootstrap Spring Applications” using “Spring Boot Initilizr With ThirdParty Tools” option.

现在,我们将讨论“如何使用带有第三方工具的Spring Boot Initilizr”选项“如何使用一些流行的第三方工具来引导Spring应用程序”。

带有第三方工具的Spring Boot Initilizr (Spring Boot Initilizr With ThirdParty Tools)

We can also use the following third party tools to bootstrap Spring Boot Applications.

我们还可以使用以下第三方工具来引导Spring Boot应用程序。

  1. CURL Tool

    CURL工具
  2. HTTPie Tool

    HTTPie工具

We will discuss these tools one by one with some simple examples in the following sections.

在以下各节中,我们将通过一些简单的示例逐一讨论这些工具。

带“ curl”工具的Spring Boot示例 (Spring Boot Example with “curl” Tool)

“curl” is an open source library and command-line tool for transferring data using various protocols like FTP,FTPS,HTTP,HTTPS,SMTP,POP3,LDAP etc. We can also use this tool to bootstrap our Spring Boot applications very easily.

“ curl”是一个开源库和命令行工具,用于使用各种协议(例如FTP,FTPS,HTTP,HTTPS,SMTP,POP3,LDAP等)传输数据。我们还可以使用此工具非常轻松地引导我们的Spring Boot应用程序。

“curl” official website is available at : https://curl.haxx.se/

“ curl”官方网站位于:https://curl.haxx.se/

“curl” provides two projects:

“ curl”提供了两个项目:

  1. cURL Project – command line tool

    cURL Project –命令行工具
  2. libcurl Project- library

    libcurl项目库

“cURL” Tool setup
Please access the “https://curl.haxx.se/download.html” URL to download “cURL” Tool.

“ cURL”工具设置
请访问“ https://curl.haxx.se/download.html”URL以下载“ cURL”工具。

I have downloaded Windows 64Bit zip file as shown below

我已经下载了Windows 64Bit zip文件,如下所示

Once download is completed, We will get a zip file as shown below. Just extract this zip file to get “curl.exe” file.

下载完成后,我们将获得如下所示的zip文件。 只需解压缩该zip文件即可获取“ curl.exe”文件。

In Windows, we need to set this System Variable:

在Windows中,我们需要设置以下系统变量:

PATH=D:\SpringBoot;%PATH%

Here “D:\SpringBoot” is my local filesystem path where “curl.exe” command is available.

这里的“ D:\ SpringBoot”是我的本地文件系统路径,其中“ curl.exe”命令可用。

“cURL” Syntax:
We need to follow the following syntax to create our Spring Boot Applications.

“ cURL”语法:
我们需要遵循以下语法来创建我们的Spring Boot Applications。

curl [options...] <url>

We can get all available options by executing “curl –help” command. to bootstrap a Spring Boot Application is Spring Initializr URL:: https://start.spring.io.

通过执行“ curl –help”命令,我们可以获得所有可用的选项。 引导Spring Boot应用程序是Spring Initializr URL :: https://start.spring.io。

When we execute “curl start.spring.io” at CMD Prompt, we can see all available Parameters, List of Spring Boot “dependencies” or “capabilities” etc.

当我们在CMD Prompt上执行“ curl start.spring.io”时,我们可以看到所有可用的参数,Spring Boot“依赖项”或“功能”列表等。

“cURL” Examples:

“ cURL”示例:

Example-1:- To create a Default Spring Boot Project

示例1:-创建默认的Spring Boot项目

curl https://start.spring.io/starter.zip -o SpringBootCurlDefaultProject.zip

It creates a Default Spring Boot project with “SpringBootCurlDefaultProject.zip” name for Maven build tool in current working directory as shown below:

它为当前工作目录中的Maven构建工具创建一个名称为“ SpringBootCurlDefaultProject.zip”的默认Spring Boot项目,如下所示:

Example-2:- To create a Spring Boot Project with required “dependencies” and required packaging type for Gradle build tool

示例2:-使用Gradle构建工具创建具有必需的“依赖关系”和必需的包装类型的Spring Boot项目

curl https://start.spring.io/starter.zip -d dependencies=web,data-jpa,jms,ws
     -d packaging=war 
     -d type=gradle-project
     -o SpringBootCurlWebProject.zip

Here we use “-d” option specify parameters.

这里我们使用“ -d”选项指定参数。

“-d type=gradle-project” means creates a Gradle project. Same way we can specify for Maven Project: “-d type=maven-project” (It is default value for “type” parameter).

“ -d type = gradle-project”表示创建Gradle项目。 我们可以为Maven项目指定的方法相同:“ -d type = maven-project”(这是“ type”参数的默认值)。

Example-3:- To create a Spring Boot Project with required “dependencies” and required packaging type for Maven build tool

示例3:-创建一个具有所需“依赖项”和所需Maven构建工具的打包类型的Spring Boot项目

curl https://start.spring.io/starter.zip 
     -d dependencies=web,jdbc,ws,cloud-aws,h2 
     -d packaging=war 
     -d type=maven-project
     -o SpringBootCurlWebMavenProject.zip

Here we use “-d” option specify parameters.

这里我们使用“ -d”选项指定参数。

“-d type=gradle-project” means creates a Gradle project. “type=maven-project” to create a Maven Project with pom.xml file(It is default value for “type” parameter).

“ -d type = gradle-project”表示创建Gradle项目。 “ type = maven-project”使用pom.xml文件创建Maven项目(这是“ type”参数的默认值)。

It creates Mavenized project with Spring MVC,Spring JDBC,Spring WS,Spring Cloud with AWS, H2 Database capabilities.

它使用Spring MVC,Spring JDBC,Spring WS,具有AWS和H2数据库功能的Spring Cloud创建Mavenized项目。

Example-4:- To create a Spring Boot Project with required “dependencies” and required packaging type for Gradle build tool by specifying Java and Spring Boot Framework version.

示例4:-通过指定Java和Spring Boot Framework版本,为Gradle构建工具创建具有必需的“依赖关系”和必需的包装类型的Spring Boot项目。

By default, “spring init” command will pickup “System Variables” and take appropriate Spring Boot and Java Versions. However it is possible to specify Spring Boot and Java Versions.

默认情况下,“ spring init”命令将提取“系统变量”并采用适当的Spring Boot和Java版本。 但是,可以指定Spring Boot和Java版本。

My Windows system is configured with Java Version = 1.8 and Spring Boot version = 1.2.3.RELEASE. However I would like to change them in creating new Spring Boot project as shown below.

我的Windows系统配置了Java版本= 1.8和Spring Boot版本= 1.2.3.RELEASE。 但是我想在创建新的Spring Boot项目时更改它们,如下所示。

curl https://start.spring.io/starter.zip 
     -d dependencies=web,jdbc,ws,cloud-aws,h2 
     -d packaging=war 
     -d type=gradle-project
     -d javaVersion=1.7
     -d bootVersion=1.2.5.RELEASE
     -o SpringBootCurlWebGradleProject.zip

Here we use “-d” option specify parameters.

这里我们使用“ -d”选项指定参数。

  • “-d javaVersion=1.7” option is used to specify Java Version like 1.7,1.8 etc.

    “ -d javaVersion = 1.7”选项用于指定Java版本,例如1.7、1.8等。
  • “-d bootVersion=1.2.5.RELEASE” option is used to specify Spring Boot Framework version like 1.2.5,1.3 etc.

    “ -d bootVersion = 1.2.5.RELEASE”选项用于指定Spring Boot Framework版本,例如1.2.5、1.3等。
  • “-d type=gradle-project” means creates a Gradle project.

    “ -d type = gradle-project”表示创建Gradle项目。
  • “type=maven-project” to create a Maven Project with pom.xml file(It is default value for “type” parameter).

    “ type = maven-project”使用pom.xml文件创建Maven项目(这是“ type”参数的默认值)。
  • “-d dependencies=web,jdbc,ws,cloud-aws,h2” specifies our Project Capabilities.

    “ -d依赖性= web,jdbc,ws,cloud-aws,h2”指定我们的项目功能。
  • “-d packaging=war” option specifies the packaging type is “war”. Default value is “jar”. It accepts “pom, jar, war, ear, rar, par”

    “ -d packaging = war”选项指定包装类型为“ war”。 默认值为“ jar”。 它接受“ pom,jar,war,ear,rar,par”

It creates Mavenized project with Spring MVC,Spring JDBC,Spring WS,Spring Cloud with AWS, H2 Database capabilities and uses Java Varsion = 1.7 and Spring Boot Framework version = 1.2.5.RELEASE.

它使用Spring MVC,Spring JDBC,Spring WS,具有AWS的Spring Cloud,H2数据库功能创建Mavenized项目,并使用Java Varsion = 1.7和Spring Boot Framework版本= 1.2.5.RELEASE。

That’s it about “curl” tool to bootstrap a Spring Boot Applications with simple commands. We can import those projects into our Spring IDEs and can enhance them as per our project requirements.

这就是关于使用简单命令来引导Spring Boot应用程序的“ curl”工具的信息。 我们可以将那些项目导入到我们的Spring IDE中,并可以根据我们的项目要求对其进行增强。

NOTE:-

注意:-

WE can refer to know the list of supported identifiers for the comma-separated list of “dependencies” at “Spring Boot Initilizr With Spring Boot CLI”.

我们可以在“使用Spring Boot CLI的Spring Boot Initilizr ”中以逗号分隔的“依赖项”列表参考支持的标识符列表。

The following section has a list of supported build options.

以下部分列出了受支持的构建选项。

+-----------------+-----------------------------------------+
| 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  |
+-----------------+-----------------------------------------+

Default build parameter value is “maven-project”

默认的构建参数值为“ maven-project”

The URI templates take a set of parameters to customize the result of a request to the linked resource..

URI模板采用一组参数来定制对链接资源的请求结果。

+-----------------+------------------------------------------+------------------------------+
| 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                      | 1.2.5.RELEASE                |
| dependencies    | dependency identifiers (comma-separated) | none                         |
| description     | project description                      | Demo project for Spring Boot |
| groupId         | project coordinates                      | org.test                     |
| javaVersion     | language level                           | 1.8                          |
| language        | programming language                     | java                         |
| name            | project name (infer application name)    | demo                         |
| packageName     | root package                             | demo                         |
| packaging       | project packaging                        | jar                          |
| type            | project type                             | maven-project                |
| version         | project version                          | 0.0.1-SNAPSHOT               |
+-----------------+------------------------------------------+------------------------------+

使用“ HTTPie”工具的Spring Boot示例 (Spring Boot Example with “HTTPie” Tool)

Like CURL tool, HTTPie is a command line HTTP client to bootstrap a Spring Boot applications with simple commands. It is a human-friendly JSON based tool. It is mainly used for testing, debugging and interacting with HTTP Web Services or Web Servers.

像CURL工具一样,HTTPie是一个命令行HTTP客户端,用于使用简单命令来引导Spring Boot应用程序。 这是一个基于JSON的人性化工具。 它主要用于测试,调试和与HTTP Web服务或Web服务器交互。

Httpie official website: https://github.com/jkbrzt/httpie

Httpie官方网站:https://github.com/jkbrzt/httpie

“HTTPie” Tool Setup

“ HTTPie”工具设置

  1. Download latest Python Windows Installer from “https://www.python.org/downloads/” and install it.

    从“ https://www.python.org/downloads/”下载最新的Python Windows Installer并进行安装。
  2. I have installed Python 2.7 as shown below. Installation is very easy with zip file. If you use Windows Installer then just follow default settings to install it.

    我已经安装了Python 2.7,如下所示。 使用zip文件安装非常容易。 如果您使用Windows Installer,则只需按照默认设置进行安装即可。

  3. Download “get-pip.py” from “https://pip.pypa.io/en/latest/installing.html#install-pip”

    从“ https://pip.pypa.io/en/latest/installing.html#install-pip”下载“ get-pip.py”
  4. Just Mouse right click and save as to your required filesystem path:

    只需鼠标右键单击并另存为所需的文件系统路径:

  5. Install “pip” by using the following command

    使用以下命令安装“ pip”
  6. python get-pip.py
  7. Install “httpie” tool by using the following command

    使用以下命令安装“ httpie”工具
  8. python -m pip install --upgrade httpie

“HTTPie” Examples

“ HTTPie”示例

Example-1:- To create a Default Spring Boot Project

示例1:-创建默认的Spring Boot项目

python -m httpie https://start.spring.io/starter.zip -d

It creates a new Spring Boot Project with default settings like: create project filename is “demo.zip”, Build tool is “Maven”. It takes default Java Version and Spring Boot Framework version from System Variables.

它使用默认设置创建一个新的Spring Boot项目,例如:创建项目文件名为“ demo.zip”,构建工具为“ Maven”。 它从系统变量中获取默认的Java版本和Spring Boot Framework版本。

Example-2:- To create a Spring Boot WebAppilcation(war) Project With required dependencies for Gradle build tool

示例2:-创建带有Gradle构建工具所需依赖项的Spring Boot WebAppilcation(war)项目

python -m httpie https://start.spring.io/starter.zip 
         dependencies==web,data-jpa,jms,ws
         type==gradle-project
         packaging==war
         -d

It creates a Gradle project with Spring MVC,Spring DATA JPA,Spring JMS,Spring WS Capabilities.

它使用Spring MVC,Spring DATA JPA,Spring JMS,Spring WS Capabilities创建一个Gradle项目。

NOTE:-Here we should observe that we need to use double equal symbols like “==” between parameter or option names and values.

注意:-在这里我们应该注意到,我们需要在参数或选项名称与值之间使用双等号,例如“ ==”。

We can refer “Curl tool” section to know the list of supported “dependencies”, “parameters” and build tool options. Both HTTPIE and Curl tools share same options and parameters.

我们可以参考“卷曲工具”部分来了解支持的“依赖关系”,“参数”和构建工具选项的列表。 HTTPIE和Curl工具共享相同的选项和参数。

That’s it all about “Spring Boot Initilizr With Thard Party Tools”.

关于“带有Thard Party Tools的Spring Boot Initilizr”的全部内容。

Please drop me a comment if you face any issues or have any suggestions.

如果您遇到任何问题或有任何建议,请给我评论。

翻译自: https://www.journaldev.com/8650/spring-boot-initilizr-with-thirdparty-tools

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值