使用Springboot是安装插件报错spring-boot-maven-plugin 插件的作用

在进行maven打包(install)的时候

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

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

jar

你还可以指定要执行的类,如果不指定的话,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. Using Spring Boot/13.1.4. Using the Spring Boot Maven plugin.html
http://www.ibm.com/developerworks/cn/java/j-lo-spring-boot/#listing1

文章来源: https://blog.csdn.net/hotdust/article/details/51404828

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值