Unable to find a single main class from the following candidates
今天在执行 mvn install的时候,报错:
按提示信息的意思,是我的这些类里面都有main方法导致的。
网上查找资料发现:
POM 文件中添加了“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>
Unable to find a single main class from the following candidates相关推荐
- SpringBoot学习之一 Unable to find a single main class from the following candidates
在启动SpringBoot项目是报错 Unable to find a single main class from the following candidates [boot.myboot.Sam ...
- 【异常】Maven构建报错 repackage failed: Unable to find a single main class from the following candidates
一.报错内容 Failed to execute goal org.springframework.boot: spring-boot-maven-plugin:2.6.11:repackage (r ...
- 异常处理(六)--------SpringBoot+Maven项目运行异常:Unable to find a single main class from the following candidat
异常详情 Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.4.2.RELEASE:run (def ...
- spring-boot-maven-plugin插件找不到含有main的主类
[背景] spring-boot项目执行mvn clean package打包时遇到一个问题,报错如下: [ERROR] Failed to execute goal org.springframew ...
- Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.4.2.RELEASE:repackage (de
使用maven 打包时报错. 错误信息: [INFO] ------------------------------------------------------------------------ ...
- 钉钉机器人项目踩过的坑
1.移动端安卓系统打开链接正常,苹果系统打开链接调用接口失败 说明:需要获得点击该链接的用户信息,因此需要使用钉钉跳转协议在钉钉当前页面打开,通过免登码的方式来获取用户信息,直接使用http协议跳转浏 ...
- Spring Boot 容器启动原理揭秘
不得不讲SpringBoot 使用起来太方便了,它的外表轻巧简单,在企业级的应用系统中非常流行,已经成为java开发者必备技能.而它采用的one-jar的方案已经深入人心,其实one-jar技术早在2 ...
- SpringBoot 的其他使用 及 maven打包
SpringBoot----开发环境/测试环境和生产环境 application.properties是SpringBoot默认加载的,全局配置,则全部放在这里,假如有需要不同环境,配置不同的参数,比 ...
- Android 使用FFmpeg3.3.9基于命令实现视频压缩
前言 首先利用linux平台编译ffmpeg的so库,具体详情请查看文章:Android NDK(ndk-r16b)交叉编译FFmpeg(3.3.9)_jszlittlecat_720的博客-CSDN ...
- Remote Development Tips and Tricks
目录 SSH tips# Configuring key based authentication# Quick start: Using SSH keys# Improving your secur ...
最新文章
- MyBatis学习总结(七)——Mybatis缓存
- 小米抢购限流峰值系统「大秒」架构解密2
- [LeetCode] Palindrome Number Valid Palindrome - 回文系列问题
- Linux初学时的一些常用命令(4)
- C语言enum关键字
- RabbitMQ 的延时队列和镜像队列原理与实战
- 从 linux内核来看进程与线程的异同
- 构建直接路由模式(DR)的LVS
- java变量和方法的覆盖和隐藏(翻译自Java Tutorials)
- 【TSP】基于matlab模拟退火算法求解旅行商问题【含Matlab源码 1129期】
- 软件测试--用例编写
- linux memtest错误但没死机,LINUX系统无故死机,系统日志报错如下,各位帮忙看看是因为什么...
- 【BZOJ2813】奇妙的Fibonacci(结论,线性筛)
- java 熄灯问题_C++基础算法学习——熄灯问题
- 温度反转效应(文末附2018数字IC后端最新校招笔试题目)
- (mac版本)IntelliJ IDEA 常用快捷键
- vc 判断哪个按键 被按下 消息 按键 状态
- P5520 [yLOI2019] 青原樱(排列组合)
- 突发事件检测: kleinberg 状态机模型
- 计算机无法识别u盘,详解电脑不识别u盘