ITPub博客

首页 > 数据库 > 数据库开发技术 > 实践bug总结--SpringBoot项目只能存在一个main函数

实践bug总结--SpringBoot项目只能存在一个main函数

原创 数据库开发技术 作者:HelloTech技术派 时间:2017-12-09 08:00:00 0 删除 编辑

问题一:异常信息如下

  1. Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.5.4.RELEASE:repackage (default) on project springcloud-hystrix-dashboard: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.5.4.RELEASE:repackage failed: Unable to find a single main class from the following candidates [com.gemantic.Server, com.gemantic.commons.ResultData] -> [Help 1]

解决方案:

通过分析日志,一个是服务的main类 com.gemantic.Server 另一个为 com.gemantic.commons.ResultData 通过查看源代码,发现此类中也有一个main方法,SpringBoot项目规范只能有一个main方法,去掉之后可以正常打包。


问题二:项目能正常打jar包,但是在执行jar时,提示无法找到含有main方法的主类

解决方案:

在pom.xml文件中增加如下配置,再重新打包就可以正常执行了

  1.  <build>

  2.    <plugins>

  3.      <plugin>

  4.        <groupId>org.springframework.boot</groupId>

  5.        <artifactId>spring-boot-maven-plugin</artifactId>

  6.        <configuration>

  7.          <fork>true</fork>

  8.          <executable>true</executable>

  9.        </configuration>

  10.      </plugin>

  11.    </plugins>

  12.  </build>


原文作者:HelloTech技术派;如有侵权,请联系管理员删除。

请登录后发表评论 登录
全部评论

注册时间:2017-12-05

  • 博文量
    181
  • 访问量
    73730