Spring Boot Initilizr Web界面

In this post, we are going to discuss about Spring Boot Initilizr Web Interface and it’s IDEs or IDE Plugins. Before reading post, please go through my previous Spring Boot posts.

在本文中,我们将讨论Spring Boot Initilizr Web Interface及其IDE或IDE插件。 在阅读文章之前,请仔细阅读我以前的Spring Boot文章。

什么是Spring Boot Initilizr (What is Spring Boot Initilizr)

Aside from Spring Boot 4 Components, Spring Boot Framework has another important key component that is: Spring Boot Initilizr.

除了Spring Boot 4组件之外,Spring Boot Framework还有另一个重要的关键组件: Spring Boot Initilizr

The Spring Team has provided a Web Interface for Spring Boot Initilizr at “https://start.spring.io/” to quick start the Development of Spring Boot Applications using Maven/Gradle build tool very easily.

Spring团队在“ https://start.spring.io/ ”处提供了用于Spring Boot Initilizr的Web界面,以非常容易地使用Maven / Gradle构建工具快速启动Spring Boot应用程序的开发。

为什么我们需要Spring Boot Initilizr (Why we need Spring Boot Initilizr)

The main aim of Spring Boot Initilizr is to start new project development within no time. It provides all required project structure and base build script files to quick start Spring Boot application without wasting time. It reduces development time.

Spring Boot Initilizr的主要目的是立即开始新项目的开发。 它提供了所有必需的项目结构和基本的构建脚本文件,以快速启动Spring Boot应用程序而不会浪费时间。 它减少了开发时间。

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 Third Party Tools

    Spring Boot Initilizr与第三方工具

We will look into “Spring Boot Initilizr With Web Interface” now with some examples and will discuss rest of three options in my coming posts.

现在,我们将通过一些示例研究“ 带有Web界面的Spring Boot Initilizr ”,并将在我的后续文章中讨论其余三个选项。

Spring Boot Initilizr Web界面 (Spring Boot Initilizr Web Interface)

The Spring Team has provided a Web Interface for Spring Boot Initilizr at “https://start.spring.io/“. We can use it to create our new Project’s base structure for Maven/Gradle build tools. It not only generates Project Base structure but also provides all required Spring Boot Jar files.

Spring团队在“ https://start.spring.io/ ”提供了用于Spring Boot Initilizr的Web界面。 我们可以使用它为Maven / Gradle构建工具创建新项目的基础结构。 它不仅生成Project Base结构,还提供所有必需的Spring Boot Jar文件。

Spring Boot Initilizr Web Interface looks like this:

Spring Boot Initilizr Web界面如下所示:

NOTE:- Combine above two images to get complete Spring Boot Initilizr Web Interface picture. I was unable to create one single image.

注意:-结合以上两个图像以获得完整的Spring Boot Initilizr Web界面图片。 我无法创建一个图像。

Now we will develop two examples one for Maven and another for Gradle build tools.

现在,我们将开发两个示例,一个用于Maven,另一个用于Gradle构建工具。

Spring Boot Initilizr Web界面Maven示例 (Spring Boot Initilizr Web Interface Maven Example)

Please follow the following steps to create new Spring Boot WebApplication for Maven Build tool and Spring STS Suite IDE (Or any IDE like Eclipse,IntelliJ IDEA etc).

请按照以下步骤为Maven Build工具和Spring STS Suite IDE(或诸如Eclipse,IntelliJ IDEA等任何IDE)创建新的Spring Boot WebApplication。

  • Please access Spring Boot Initilizr at “https://start.spring.io/“.

    请通过“ https://start.spring.io/ ”访问Spring Boot Initilizr。
  • Provide our project Required details and Click on “Generate Project” Button

    提供我们的项目所需的详细信息,然后单击“生成项目”按钮
  • I have provided all our Maven project’s required details and selected required technologies check boxes as shown in the diagram.

    我提供了所有Maven项目所需的详细信息,并选择了所需的技术复选框,如图所示。

    I have selected H2 Database and Click on “Generate Project” Button

    我选择了H2数据库,然后单击“生成项目”按钮

  • When we click on “Generate Project” Button, it creates and downloads a Maven Project as “SpringMVCMavenProject.zip” file into our local file system.

    当我们单击“生成项目”按钮时,它将创建一个Maven项目并将其作为“ SpringMVCMavenProject.zip”文件下载到我们的本地文件系统中。
  • Copy “SpringMVCMavenProject.zip” to our Spring STS Suite Workspace and Extract this zip file

    将“ SpringMVCMavenProject.zip”复制到我们的Spring STS Suite工作区并解压缩该zip文件
  • Import this “SpringMVCMavenProject” Maven project into Spring STS IDE

    将此“ SpringMVCMavenProject” Maven项目导入到Spring STS IDE中
  • This “SpringMVCMavenProject” Maven project structure looks like

    这个“ SpringMVCMavenProject” Maven项目结构看起来像
  • If you observe this project files, it generates pom.xml file, two Spring Boot Java files and one JUnit Java file.

    如果观察该项目文件,它将生成pom.xml文件,两个Spring Boot Java文件和一个JUnit Java文件。

    “pom.xml”

    “ pom.xml”



	4.0.0

	com.journaldev
	SpringMVCMavenProject
	0.0.1-SNAPSHOT
	war

	SpringMVCMavenProject
	Demo project for Spring Boot

	
		org.springframework.boot
		spring-boot-starter-parent
		1.2.5.RELEASE
		 
	

	
		UTF-8
		1.8
	

	
		
			org.springframework.boot
			spring-boot-starter-data-jpa
		
		
			org.springframework.boot
			spring-boot-starter-web
		
		
			org.springframework.boot
			spring-boot-starter-ws
		
		
		
			com.h2database
			h2
			runtime
		
		
			org.springframework.boot
			spring-boot-starter-tomcat
			provided
		
		
			org.springframework.boot
			spring-boot-starter-test
			test
		
		
	
		
			
				org.springframework.boot
				spring-boot-maven-plugin
			
		
	

NOTE:- We will discuss about this Java Source code and execution of this code and also discuss about “SpringApplication” class in my coming post.

注意:我们将在我的后续文章中讨论有关此Java源代码和此代码的执行,并讨论“ SpringApplication”类。

ServletInitializer.java

ServletInitializer.java

package SpringMVCMavenProject;

import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;

public class ServletInitializer extends SpringBootServletInitializer {

	@Override
	protected SpringApplicationBuilder 
                        configure(SpringApplicationBuilder application) {
		return application.sources(SpringMvcMavenProjectApplication.class);
	}

}

SpringMvcMavenProjectApplication.java

SpringMvcMavenProjectApplication.java

package SpringMVCMavenProject;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class SpringMvcMavenProjectApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringMvcMavenProjectApplication.class, args);
    }
}

SpringMvcMavenProjectApplicationTests.java

SpringMvcMavenProjectApplicationTests.java

package SpringMVCMavenProject;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration
              (classes=SpringMvcMavenProjectApplication.class)
@WebAppConfiguration
public class SpringMvcMavenProjectApplicationTests {

	@Test
	public void contextLoads() {
	}

}

Spring Boot Initilizr Web界面Gradle示例 (Spring Boot Initilizr Web Interface Gradle Example)

Like Maven Example, Please follow the following steps to create new Spring Boot WebApplication for Gradle Build tool and Spring STS Suite IDE.

与Maven示例类似,请按照以下步骤为Gradle Build工具和Spring STS Suite IDE创建新的Spring Boot WebApplication。

  • Please access Spring Boot Initilizr at “https://start.spring.io/“.

    请通过“ https://start.spring.io/ ”访问Spring Boot Initilizr。
  • Provide our project Required details and Click on “Generate Project” Button

    提供我们的项目所需的详细信息,然后单击“生成项目”按钮
  • I have provided all our Gradle project’s required details and selected required technologies check boxes as shown in the diagram.

    我已经提供了所有Gradle项目所需的详细信息,并选择了所需的技术复选框,如图所示。

    NOTE:- Here only difference from previous Maven project is Changing “Type” from “Maven Project” to “Gradle Project”. Like this we can select Java Version, Language(Java,Groovy), Required Project technologies etc and create new project very easily.

    注意:-这里与以前的Maven项目唯一的区别是将“类型”从“ Maven项目”更改为“渐变项目”。 这样,我们可以选择Java版本,语言(Java,Groovy),必需的项目技术等,并非常容易地创建新项目。

    I have selected H2 Database and Click on “Generate Project” Button

    我选择了H2数据库,然后单击“生成项目”按钮

  • When we click on “Generate Project” Button, it creates and downloads a Gradle Project as “SpringMVCGradleProject.zip” file into our local file system.

    当我们单击“ Generate Project”按钮时,它将创建Gradle Project并将其作为“ SpringMVCGradleProject.zip”文件下载到我们的本地文件系统中。
  • Copy “SpringMVCGradleProject.zip” to our Spring STS Suite Workspace and Extract this zip file

    将“ SpringMVCGradleProject.zip”复制到我们的Spring STS Suite工作区并解压缩该zip文件
  • Import this “SpringMVCGradleProject” Gradle project into Spring STS IDE

    将此“ SpringMVCGradleProject” Gradle项目导入到Spring STS IDE中
  • This “SpringMVCGradleProject” Gradle project structure looks like as shown Maven project except pom.xml file change to build.gradle

    除了将pom.xml文件更改为build.gradle外,此“ SpringMVCGradleProject” Gradle项目结构类似于所示的Maven项目。
  • If you observe this project files, it generates build.gradle file, two Spring Boot Java files and one JUnit Java file (These 3 Java files are similar to Maven Project).

    如果您观察到此项目文件,它将生成build.gradle文件,两个Spring Boot Java文件和一个JUnit Java文件(这3个Java文件类似于Maven Project)。

    Genernate “build.gradle” file content:

    生成“ build.gradle”文件内容:

buildscript {
   ext {
     springBootVersion = '1.2.5.RELEASE'
   }
   repositories {
     mavenCentral()
   }
   dependencies {
     classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 
     classpath("io.spring.gradle:dependency-management-plugin:0.5.2.RELEASE")
   }
}

apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'idea'
apply plugin: 'spring-boot' 
apply plugin: 'io.spring.dependency-management' 
apply plugin: 'war'

war {
    baseName = 'SpringMVCGradleProject'
    version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    mavenCentral()
}

configurations {
    providedRuntime
}

dependencies {
    compile("org.springframework.boot:spring-boot-starter-data-jpa")
    compile("org.springframework.boot:spring-boot-starter-web")
    compile("org.springframework.boot:spring-boot-starter-ws")
    runtime("com.h2database:h2")
    providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
    testCompile("org.springframework.boot:spring-boot-starter-test") 
}

eclipse {
    classpath {
         containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
         containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8'
    }
}

task wrapper(type: Wrapper) {
    gradleVersion = '2.3'
}

That’s about Spring Boot Initilizr With Web Interface.

那是关于带有Web界面的Spring Boot Initilizr。

We will discuss about Java Source code, Importance of “SpringApplication” class and its “SpringApplication.run()” method, How to run this Application etc in my coming posts at “Spring Boot Initilizr With IDEs or IDE Plugins”, “Spring Boot Initilizr With Spring Boot CLI” and “Spring Boot Initilizr With ThirdParty Tools” in my coming post.

我们将在我的即将发布的文章“带有IDE或IDE插件的Spring Boot Initilizr”“ Spring Boot ”中讨论Java源代码,“ SpringApplication”类的重要性及其“ SpringApplication.run()”方法,如何运行此应用程序等问题。在我即将发布的文章中, 使用Spring Boot CLI进行Initilizr”“使用ThirdParty Tools进行Spring Boot进行Initilizr”

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

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

翻译自: https://www.journaldev.com/8225/spring-boot-initilizr-web-interface

你可能感兴趣的:(Spring Boot Initilizr Web界面)