zoukankan      html  css  js  c++  java
  • spring-boot-maven-plugin 插件的作用(转)

    OM 文件中添加了“org.springframework.boot:spring-boot-maven-plugin”插件。在添加了该插件之后,当运行“mvn package”进行打包时,会打包成一个可以直接运行的 JAR 文件,使用“Java -jar”命令就可以直接运行。这在很大程度上简化了应用的部署,只需要安装了 JRE 就可以运行。

    可以在POM中,指定生成 的是Jar还是War。

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <!-- ... -->
    <packaging>jar</packaging>
    <!-- ... -->
    </project>

    你还可以指定要执行的类,如果不指定的话,Spring会找有这个【public static void main(String[] args)】方法的类,当做可执行的类。

    如果你想指定的话,可以用下面两个方法:

    1,如果你的POM是继承spring-boot-starter-parent的话,只需要下面的指定就行。

    <properties>
        <!-- The main class to start by executing java -jar -->
        <start-class>com.mycorp.starter.HelloWorldApplication</start-class>
    </properties>

    2,如果你的POM不是继承spring-boot-starter-parent的话,需要下面的指定。

        <plugin>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-maven-plugin</artifactId>
          <version>1.3.5.RELEASE</version>
          <configuration>
            <mainClass>${start-class}</mainClass>
            <layout>ZIP</layout>
          </configuration>
          <executions>
            <execution>
              <goals>
                <goal>repackage</goal>
              </goals>
            </execution>
          </executions>
        </plugin>

    from:

    http://docs.spring.io/spring-boot/docs/current/maven-plugin/usage.html
    http://stackoverflow.com/questions/23217002/how-do-i-tell-spring-boot-which-main-class-to-use-for-the-executable-jar
    http://docs.spring.io/spring-boot/docs/current/maven-plugin/repackage-mojo.html
    http://udn.yyuap.com/doc/Spring-Boot-Reference-Guide/III.%20Using%20Spring%20Boot/13.1.4.%20Using%20the%20Spring%20Boot%20Maven%20plugin.html
    http://www.ibm.com/developerworks/cn/java/j-lo-spring-boot/#listing1

  • 相关阅读:
    gulp-css-spriter 将css代码中的切片图片合并成雪碧图
    通过JS模拟select表单,达到美化效果[demo]
    jQuery拖拽 & 弹出层
    sublime text 快速编码技巧 GIT图
    原生JS不到30行,实现类似javascript MVC的功能-minTemplate
    javascript拖拽原理与简单实现方法[demo]
    滚动焦点图实现原理和实践[原创视频]
    谈一谈值类型与引用类型和装箱与拆箱
    【原创】asp.net内部原理(三) 第三个版本 (最详细的版本)
    由JS函数返回值引发的一场”血案"
  • 原文地址:https://www.cnblogs.com/panxuejun/p/6667490.html
Copyright © 2011-2022 走看看