转自:http://blog.csdn.net/hotdust/article/details/51404828

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>

spring-boot-maven-plugin插件作用的更多相关文章

  1. Spring Boot Maven Plugin(二):run目标

    简介 Spring Boot Maven Plugin插件提供spring boot在maven中的支持.允许你打包可运行的jar包或war包. 插件提供了几个maven目标和Spring Boot ...

  2. Spring Boot Maven Plugin(一):repackage目标

    简介 Spring Boot Maven Plugin插件提供spring boot在maven中的支持.允许你打包可运行的jar包或war包. 插件提供了几个maven目标和Spring Boot ...

  3. Spring Boot的Maven插件Spring Boot Maven plugin详解

    Spring Boot的Maven插件(Spring Boot Maven plugin)能够以Maven的方式为应用提供Spring Boot的支持,即为Spring Boot应用提供了执行Mave ...

  4. Spring Boot Maven Plugin打包异常及三种解决方法:Unable to find main class

    [背景]spring-boot项目,打包成可执行jar,项目内有两个带有main方法的类并且都使用了@SpringBootApplication注解(或者另一种情形:你有两个main方法并且所在类都没 ...

  5. 微服务下 Spring Boot Maven 工程依赖关系管理

    单体 Spring Boot Maven 工程 最基本的 pom.xml 包含工程信息.Spring Boot 父工程.属性配置.依赖包.构建插件 <?xml version="1.0 ...

  6. spring boot集成mybatis-plus插件进行自定义sql方法开发时报nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

    spring boot集成mybatis-plus插件进行自定义sql方法开发时报nested exception is org.apache.ibatis.binding.BindingExcept ...

  7. spring boot maven META-INF/MAINIFEST.MF

    unzip -p charles.jar META-INF/MANIFEST.MF https://blog.csdn.net/isea533/article/details/50278205 htt ...

  8. spring boot maven打包可运行jar包

    普通打包之后在程序目录运行,或者编写bat运行时会提示“没有主清单属性”,这是因为并没有找到main()方法,需要我们指明告诉java程序 我bat中的代码 @echo off title mytit ...

  9. Spring boot+ maven + thymeleaf + HTML 实现简单的web项目

    第一步: 创建一个SpringBoot应用 第二步: 创建一个实体,用来存储数据,在src/main/java/com/example/first下创建包entity , 在entity下创建Pers ...

  10. 一步步搭建 Spring Boot maven 框架的工程

    摘要:让Spring应用从配置到运行更加快速,演示DIY Spring Boot 框架时,如何配置端口号,如何添加日志. Spring Boot 框架帮助开发者更容易地创建基于Spring的应用程序和 ...

随机推荐

  1. GTID 跳过脚本

    跳过单个error STOP SLAVE; SET gtid_next = '3b977b7e-ed28-11e7-a8ff-b4969113b678:138609841'; BEGIN;COMMIT ...

  2. 20181106_线程之异常_取消_变量_安全Lock

    一. 线程的异常处理: try { TaskFactory taskFactory = new TaskFactory(); List<Task> taskList = new List& ...

  3. 深入浅出 Java Concurrency (13): 锁机制 part 8 读写锁 (ReentrantReadWriteLock) (1)

      从这一节开始介绍锁里面的最后一个工具:读写锁(ReadWriteLock). ReentrantLock 实现了标准的互斥操作,也就是一次只能有一个线程持有锁,也即所谓独占锁的概念.前面的章节中一 ...

  4. python第三方库推荐 - dateutil

    在dateutil中,吸引我的东西有2个,1个是parser,1个是rrule. 其中parser是根据字符串解析成datetime,而rrule是则是根据定义的规则来生成datetime. 安装 没 ...

  5. python与冒泡排序

    上一篇文章,介绍了一个非常快的排序算法--桶排序,但是它的缺点就是太耗资源了,这次要实现的算法就不用太耗资源了,它就是冒泡排序. 问题提出: 将以下数据升序排列:9, 2, 8, 6, 4 冒泡排序原 ...

  6. leetcode289

    public class Solution { public void GameOfLife(int[][] board) { ) - ; ].GetLength() - ; var list = n ...

  7. YUV图像合成原理<转>

    YUV图像合成原理 引言:在视频监控中最常用的就是图像拼接和字符叠加,25FPS的视频流,如果每隔40MS就从各个通道中取一幅图像来合成,则可以看到一个实时的合成视频.合成的过程也就是原始图像的拼接. ...

  8. ElasticSearch中如何让query should等同于filter should

    bool query must The clause (query) must appear in matching documents. should The clause (query) shou ...

  9. cdn path b 问题

    主节点内存和磁盘最好大点,许多默认东西都放主节点了 mysql 配置文件修改后server-id = 1 1.hive 启动不起来 去配置里关掉 严格的 Hive Metastore 架构验证 hiv ...

  10. tomcat https

    转自 http://11lingxian.iteye.com/blog/1491607 双向认证: 客户端向服务器发送消息,首先把消息用客户端证书加密然后连同时把客户端证书一起发送到服务器端, 服务器 ...