简体   繁体   English

spring-boot-maven-plugin:加载在哪里?

[英]spring-boot-maven-plugin: where it is loaded?

I am trying to implement step by step all instructions that are defined here: 我正在尝试逐步实现此处定义的所有指令:

Spring Boot Reference Guide Spring Boot参考指南

and I have got a question regarding section: 11.4 Running the example 我对以下部分有疑问: 11.4运行示例

They wrote: 他们写:

At this point our application should work. 此时,我们的应用程序应该可以工作了。 Since we have used the spring-boot-starter-parent POM we have a useful run goal that we can use to start the application. 由于我们已经使用了spring-boot-starter-parent父POM,因此我们有了一个有用的运行目标,可以用来启动该应用程序。 Type mvn spring-boot:run from the root project directory to start the application 从根项目目录键入mvn spring-boot:run以启动应用程序

I did not add spring-boot-maven-plugin directly to my pom.xml 我没有将spring-boot-maven-plugin直接添加到我的pom.xml中

I see that in spring-boot-starter-parent module spring-boot-maven-plugin are defined in pom.xml only in < pluginManagement> section, it means that in parent module only default configuration for plugin described. 我看到在spring-boot-starter-parent模块中,仅在<pluginManagement>部分中的pom.xml中定义了spring-boot-maven-plugin ,这意味着在父模块中,仅描述了插件的默认配置。

And now I can't understand how and where the plugin is loaded? 现在我不明白插件的加载方式和位置

As stated in the documentation , Maven is just a collection of plugins that do everything your project needs to be correctly compiled. 文档中所述,Maven只是插件的集合,可以完成项目需要正确编译的所有事情。

But note that you don't explicitly declare a vast majority of them. 但是请注意,您并未明确声明其中的绝大多数。 For example, the Clean plugin (which removes the target directory) is not declared in your pom, but if you type mvn clean the plugin is loaded and executed. 例如,未在pom中声明Clean插件(用于删除目标目录),但是如果您键入mvn clean ,则会加载并执行该插件。

It's Maven itself that loads the plugin and it's the same with spring-boot-maven-plugin , as long as you have a configuration for this plugin, which is the case as you declare the spring-boot-starter-parent as your parent. Maven本身会加载插件,并且与spring-boot-maven-plugin ,只要您对此插件进行了配置即可(在您声明spring-boot-starter-parent为父母的情况下就是这种情况)。

To further understand this, you can try the build configuration described in 13.2.2 Using Spring Boot without the Parent POM of this Spring documentation. 为了进一步了解这一点,您可以尝试使用 本Spring文档中 没有父POM13.2.2使用Spring Boot中描述的构建配置

You'll see that if you don't explicitely include the spring boot plugin, you'll get an error "No plugin found for prefix 'spring-boot' in the current project" 您将看到,如果您未明确包含spring boot插件,则会收到错误消息“在当前项目中未找到前缀为'spring-boot'的插件”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM