This is continuation to my previous post. Before reading this post, please go through my previous post at “Spring Boot Initilizr Web Interface“.

这是我上一篇文章的延续。 在阅读本文之前,请仔细阅读我以前的文章“ Spring Boot Initilizr Web Interface ”。

简报内容 (Brief Post Content)

  • Spring Boot Initilizr With IDEs/IDE Plugins
    具有IDE / IDE插件的Spring Boot Initilizr
  • Execute Spring Boot Application With IDEs/IDE Plugins
    使用IDE / IDE插件执行Spring Boot应用程序
  • Internals and Importance of “SpringApplication” class
    “ SpringApplication”类的内部和重要性

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

We have already discussed Spring Boot Initilizr With Web Interface in my previous post. Now we are going to discuss on “How to use Spring Boot Initilizr with IDEs/IDE Plugins”. Almost all Java IDEs provides Spring Boot plugins.

在我以前的文章中,我们已经讨论了带有Web界面的Spring Boot Initilizr。 现在,我们将讨论“如何将Spring Boot Initilizr与IDE / IDE插件一起使用”。 几乎所有的Java IDE都提供Spring Boot插件。

We are going to use Spring STS Suite to develop all our Spring Boot programs. By default, Spring STS Suite comes with Spring Boot Plugins, no need to install/configure it.

我们将使用Spring STS Suite开发所有的Spring Boot程序。 默认情况下,Spring STS Suite附带有Spring Boot插件,无需安装/配置。

具有IDE / IDE插件的Spring Boot Initilizr (Spring Boot Initilizr With IDEs/IDE Plugins)

Please follow the following steps to create a Spring MVC Maven project with Spring STS Suite.(Almost similar steps with other IDEs too.)

请按照以下步骤使用Spring STS Suite创建一个Spring MVC Maven项目(其他IDE几乎也是如此)。

  • Please select “Spring Stater Project” Menu option from “File >> New” Menu as shown below.
    请从“文件>>新建”菜单中选择“ Spring Stater项目”菜单选项,如下所示。
  • If you don’t fine “Spring Stater Project” option directly in “New” menu, then select this option from “File >> New >> Other” under “Spring” category.

    如果您不直接在“新建”菜单中对“ Spring Stater Project”选项进行优化,则从“ Spring”类别下的“文件>>新建>>其他”中选择此选项。

  • We will get the following “New Spring Stater Project” Wizard to provide our project related information
    我们将获得以下“ New Spring Stater Project”向导,以提供与项目相关的信息
  • Please provide our Spring MVC Maven WebApplication Project details as shown below and Click on “Next” Button
    请提供我们的Spring MVC Maven WebApplication项目详细信息,如下所示,然后单击“下一步”按钮
  • Here we can select Project Type: Maven Project or Gradle Project, Language: Java or Groovy, Java Version, Packaging: Jar or War etc.

    在这里,我们可以选择项目类型:Maven项目或Gradle项目,语言:Java或Groovy,Java版本,包装:Jar或War等。

  • Select our Project related Technology Stack as shown below and Click on “Finish” button to create our new Spring Boot Project
    选择我们与项目相关的技术堆栈,如下所示,然后单击“完成”按钮以创建我们的新Spring Boot项目。
  • Here we can select Spring Boot Framework Version: 1.2.5 and all our Project required Technology Stack.

    在这里,我们可以选择Spring Boot Framework Version:1.2.5和我们所有项目所需的技术堆栈。

  • Now Spring STS Suite creates a Maven Project and downloads all required Jars to our Maven Local Repository.
    现在,Spring STS Suite将创建一个Maven项目,并将所有必需的Jar下载到我们的Maven本地存储库中。
  • If we observe this project structure, pom.xml and Java Source files, they all are similar to the files we have created by using “Spring Boot Initilizr With Web Interface“.
    如果我们观察这个项目结构pom.xml和Java Source文件,它们都类似于我们使用“ 带有Web界面的Spring Boot Initilizr ”创建的文件。

NOTE:-
In the same way, we can create JARs, Gradle projects, Spring Web Services, Spring REST API, Spring Cloud etc.

注意:-
以相同的方式,我们可以创建JAR,Gradle项目,Spring Web Services,Spring REST API,Spring Cloud等。

执行Spring Boot应用程序 (Execute Spring Boot Application)

We have created Spring Boot WebApplication using Spring STS IDE. It’s time to run this application and observe the results.

我们已经使用Spring STS IDE创建了Spring Boot WebApplication。 现在该运行该应用程序并观察结果了。

  • Mouse Right click on “SpringMvcMavenIdeProjectApplication.java” file and select “Spring Boot App” option from “Run As” Menu to run this Program as Spring Boot Application as shown below
    鼠标右键单击“ SpringMvcMavenIdeProjectApplication.java”文件,然后从“运行方式”菜单中选择“ Spring Boot应用程序”选项以将该程序作为Spring Boot应用程序运行,如下所示
  • NOTE:- Why we need to run “SpringMvcMavenIdeProjectApplication.java” Program?
    Because “SpringMvcMavenIdeProjectApplication.java” program has Java’s main() method. We will see the importance of “SpringApplication.run()” method soon.

    注意:-为什么我们需要运行“ SpringMvcMavenIdeProjectApplication.java”程序?
    因为“ SpringMvcMavenIdeProjectApplication.java”程序具有Java的main()方法。 我们将很快看到“ SpringApplication.run()”方法的重要性。

  • When we execute “SpringMvcMavenIdeProjectApplication.java” program, Spring Boot automatically does the following things:
    当我们执行“ SpringMvcMavenIdeProjectApplication.java”程序时,Spring Boot会自动执行以下操作:
  1. Creates a Spring MVC application
    创建一个Spring MVC应用程序
  2. Starts Embedded Tomcat Server with default port number: 8080
    使用默认端口号8080启动嵌入式Tomcat服务器
  3. Deploy our Spring MVC application into Tomcat Sever
    将我们的Spring MVC应用程序部署到Tomcat Sever中

  • Access our Spring MVC application with “https://localhost:8080/SpringMVCMavenIDEProject” or “https://localhost:8080/*” and observe the results
    使用“ https:// localhost:8080 / SpringMVCMavenIDEProject”或“ https:// localhost:8080 / *”访问我们的Spring MVC应用程序,并观察结果
  • Here * means any URI or Context Path

    此处*表示任何URI或上下文路径

    As we don’t provide any mappings or View Pages(ex:- JSPs), we are seeing default error page.

    由于我们不提供任何映射或视图页面(例如:-JSP),因此我们看到了默认错误页面。

    NOTE:-

    注意:-

    1. Use this base Spring Boot WebApplication project and enhance it with your project requirements.
      使用这个基本的Spring Boot WebApplication项目并根据您的项目要求对其进行增强。
    2. We can also use Spring STE IDE generated “SpringMvcMavenIdeProjectApplicationTests.java” class to execute and test our Spring Boot Application
      我们还可以使用Spring STE IDE生成的“ SpringMvcMavenIdeProjectApplicationTests.java”类来执行和测试我们的Spring Boot应用程序
    3. Mouse Right click on “SpringMvcMavenIdeProjectApplicationTests.java” class and Select “Run As >> JUnit Test” option.
      鼠标右键单击“ SpringMvcMavenIdeProjectApplicationTests.java”类,然后选择“运行方式>> JUnit测试”选项。

    “ SpringApplication”类的内部和重要性 (Internals and Importance of “SpringApplication” class)

    Now, We will discuss about What is SpringApplication? Why we need this? The importance of SpringApplication? The internals of SpringApplication?

    现在,我们将讨论什么是SpringApplication? 为什么我们需要这个? SpringApplication的重要性? SpringApplication的内部?

    • “SpringApplication” is one of the Spring Boot API classes.
      “ SpringApplication”是Spring Boot API类之一。
    • SpringApplication class is used to bootstrap a Spring application that will be started from a “main()” method
      SpringApplication类用于引导将从“ main()”方法启动的Spring应用程序
    • Example:-
      Spring STS IDE Generated class: “SpringMvcMavenIdeProjectApplication”

      例:-
      Spring STS IDE生成的类:“ SpringMvcMavenIdeProjectApplication”

    package com.journaldev.springboot.sample;import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplication
    public class SpringMvcMavenIdeProjectApplication {public static void main(String[] args) {SpringApplication.run(SpringMvcMavenIdeProjectApplication.class, args);}
    }

    We are making a call to SpringApplication.run() from the main() method of SpringMvcMavenIdeProjectApplication class.

    我们正在从SpringMvcMavenIdeProjectApplication类的main()方法调用SpringApplication.run()。

  • SpringMvcMavenIdeProjectApplication class is annotated with @SpringBootApplication annotation
    SpringMvcMavenIdeProjectApplication类使用@SpringBootApplication注释进行注释
  • @SpringBootApplication = @Configuration + @EnableAutoConfiguration + @ComponentScan

    @SpringBootApplication = @配置+ @EnableAutoConfiguration + @ComponentScan

    @SpringBootApplication does the following things:

    @SpringBootApplication执行以下操作:

    1. Because of @Configuration annotation, It scans for @Bean methods to create beans.
      由于使用@Configuration批注,因此它将扫描@Bean方法以创建bean。
    2. Because of @ComponentScan annotation, It does component scanning (Components means Beans annotated with @Component,@Service,@Repository,@Controller etc).
      由于使用@ComponentScan批注,因此它进行组件扫描(“组件”表示使用@ Component,@ Service,@ Repository,@ Controller注释的Bean)。
    3. Because of @EnableAutoConfiguration annotation, It triggers Spring Boot Auto-Configuration.
      由于@EnableAutoConfiguration注释,它将触发Spring Boot自动配置。
  • By default, SpringApplication class creates “AnnotationConfigEmbeddedWebApplicationContext” instance
    默认情况下,SpringApplication类创建“ AnnotationConfigEmbeddedWebApplicationContext”实例
  • “AnnotationConfigEmbeddedWebApplicationContext” instance searches JAR files in our Project Classpath. Based on JARs found at Classpath, it creates an instance of one of the implemented class of “EmbeddedServletContainerFactory” interface
    “ AnnotationConfigEmbeddedWebApplicationContext”实例在我们的项目类路径中搜索JAR文件。 基于在Classpath上找到的JAR,它创建“ EmbeddedServletContainerFactory”接口的已实现类之一的实例。
  • Example:-
    By default, Spring STS IDE adds all required Tomcat Container JARs to our newly created Spring Boot Project Classpath. That’s why “AnnotationConfigEmbeddedWebApplicationContext” instance creates an instance of “TomcatEmbeddedServletContainerFactory” class.

    例:-
    默认情况下,Spring STS IDE将所有必需的Tomcat容器JAR添加到我们新创建的Spring Boot Project Classpath中。 这就是为什么“ AnnotationConfigEmbeddedWebApplicationContext”实例创建“ TomcatEmbeddedServletContainerFactory”类的实例的原因。

  • “EmbeddedServletContainerFactory” (“JettyEmbeddedServletContainerFactory” or “TomcatEmbeddedServletContainerFactory”) is used to create an instance of a “EmbeddedServletContainer” implementations.
    “ EmbeddedServletContainerFactory”(“ JettyEmbeddedServletContainerFactory”或“ TomcatEmbeddedServletContainerFactory”)用于创建“ EmbeddedServletContainer”实现的实例。
  • Example:-
    By default, Spring STS IDE creates an instance of “TomcatEmbeddedServletContainerFactory” class. This factory is used to create an instance of “TomcatEmbeddedServletContainer” class.

    例:-
    默认情况下,Spring STS IDE创建一个“ TomcatEmbeddedServletContainerFactory”类的实例。 该工厂用于创建“ TomcatEmbeddedServletContainer”类的实例。

  • When we run SpringMvcMavenIdeProjectApplication class main() method, it make a calls to “SpringApplication.run()” method.
    当我们运行SpringMvcMavenIdeProjectApplication类main()方法时,它将调用“ SpringApplication.run()”方法。
  • “SpringApplication.run()” method in Spring STS IDE

    Spring STS IDE中的“ SpringApplication.run()”方法

    1. This call is used to create “AnnotationConfigEmbeddedWebApplicationContext”.
      该调用用于创建“ AnnotationConfigEmbeddedWebApplicationContext”。
    2. This “AnnotationConfigEmbeddedWebApplicationContext” instance is used to create an instance of “TomcatEmbeddedServletContainerFactory” class.
      此“ AnnotationConfigEmbeddedWebApplicationContext”实例用于创建“ TomcatEmbeddedServletContainerFactory”类的实例。
    3. This “TomcatEmbeddedServletContainerFactory” is used to create an instance of “TomcatEmbeddedServletContainer” class.
      该“ TomcatEmbeddedServletContainerFactory”用于创建“ TomcatEmbeddedServletContainer”类的实例。
    4. “TomcatEmbeddedServletContainer” instance starts a Tomcat Container at default port number: 8080 and deploys our Spring Boot WebApplication.
      “ TomcatEmbeddedServletContainer”实例在默认端口号8080上启动Tomcat容器,并部署我们的Spring Boot WebApplication。

    That’s it about Spring Boot Initilizr With IDEs/IDE Plugins and Importance of “SpringApplication” class.

    关于带有IDE / IDE插件的Spring Boot Initilizr和“ SpringApplication”类的重要性。

    We will discuss about “Spring Boot Initilizr With Spring Boot CLI“ and “Spring Boot Initilizr With ThirdParty Tools” in my coming post.

    我们将在我的后续文章中讨论“ 使用Spring Boot CLI的 Spring Boot Initilizr 和“ 使用ThirdParty Tools的Spring Boot Initilizr ”。

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

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

    翻译自: https://www.journaldev.com/8596/spring-boot-initilizr-with-ides-or-ide-plugins

具有IDE或IDE插件的Spring Boot Initilizr相关推荐

  1. Spring Boot Initilizr - 使用IDE或IDE插件

    Spring Boot Initilizr 使用IDE或IDE插件 这是我之前的帖子的延续.在阅读这篇文章之前,请先阅读我在" Spring Boot Initilizr Web界面 &qu ...

  2. Spring Boot Initilizr - 使用Spring Boot CLI

    Spring Boot Initilizr - 使用Spring Boot CLI 这是我之前的两篇文章的延续.在阅读本文之前,请先阅读我之前在" Spring Boot Initilizr ...

  3. Spring Boot Initilizr - 使用ThirdParty工具

    Spring Boot Initilizr - 使用ThirdParty工具 这是我之前的两篇文章的延续.在阅读本文之前,请先阅读我之前在" Spring Boot Initilizr We ...

  4. Spring Boot Initilizr Web界面

    Spring Boot Initilizr Web界面 在这篇文章中,我们将讨论Spring Boot Initilizr Web Interface及其IDE或IDE插件.在阅读帖子之前,请查看我之 ...

  5. 使用Spring Boot CLI的Spring Boot Initilizr

    This is continuation to my two previous posts. Before reading this post, please go through my previo ...

  6. 带有第三方工具的Spring Boot Initilizr

    This is continuation to my two previous posts. Before reading this post, please go through my previo ...

  7. 用idea插件将一个spring boot项目部署到docker容器里运行

    修改docker配置文件 1.编辑docker.service脚本 /usr/lib/systemd/system/docker.service 2.在docker.service中加入脚本并保存退出 ...

  8. Spring Boot 面试问题

    Spring Boot 面试问题 今天我们将研究一些春季靴子面试的问题和答案.到目前为止,我们已经讨论了一些关于Spring BootFramework的帖子以及一些实时示例.在这篇文章中,我将向您简 ...

  9. spring boot面试_Spring Boot面试问题

    spring boot面试 Today we will look into some spring boot interview questions and answers. So far, we h ...

最新文章

  1. C#让windows程序只运行一次
  2. week6 10 后端backend server和mongoDB通信
  3. python模拟内置函数reversed_Python内置函数reversed
  4. c++STL之vector简易使用
  5. sharepoint 2007页面显示真实的错误信息
  6. idea打开hierarchy面板
  7. 「学习记录」《数值分析》第二章计算实习题(Python语言)
  8. 计算地球上两点的直线距离
  9. linux中安装mysql_Linux下安装MySQL
  10. 小程序 做二维码带logo绘制二维码
  11. 黑马程序员机器学习Day1学习笔记
  12. 标志寄存器(PSW)
  13. ReactJS几款UI框架
  14. MTK交换机PHY 方案Airoha达发(econet)概要
  15. 怎么制作有趣的表情包
  16. huggingFace 中文模型实战——中文文本分类
  17. 高考计算机会考等级划分标准,学考等级怎么划分2020最新标准
  18. Win10设置系统补丁更新服务器,win10如何关闭自动更新补丁_win10关闭自动更新补丁的图文教程...
  19. PREEMPT-RT
  20. SQL优化不会?推荐4 款工具

热门文章

  1. Guacamole-HTML5无客户端远程桌面
  2. [转载] 十种方式拼接Python字符串
  3. 使用ViewPager + Fragment实现微信底部Tab效果
  4. 捷信达会员管理系统SQL语句相关
  5. zbb20180613 Spring MVC实现大文件下载功能
  6. JavaSE-22 反射
  7. 因特网人群信息的应用-通过人群性格特点投放定制广告
  8. JavaWeb之多语言国际化
  9. [转]深入理解Java 8 Lambda(语言篇——lambda,方法引用,目标类型和默认方法)...
  10. Repository 仓储,你的归宿究竟在哪?(三)-SELECT 某某某。。。