当前位置:网站首页>记一次服务部署失败问题排查
记一次服务部署失败问题排查
2022-07-01 02:28:00 【luxinfeng666】
背景
上周五的时候某一功能本地开发完成后,需要部署到线下环境进行前后端联调。在部署的时候提示“进程反复重启”从而部署失败,在本地启动时代码可以正常启动。
排查过程
首先登录部署的线下机器,查看部署日志,发现日志中提示“war包损坏或失效”。解压war包,提示war包为空,因此应该是构建打包的时候发生了错误(在构建打包时,公司的平台上一直提示的都是构建打包成功,所以一开始以为是编译或者部署的脚本发生了问题,检查后发现都没有问题)。
然后检查构建打包的日志,发现这个地方果然出错了,出错原因为
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.6.7:repackage (repackage) on project demo: Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:2.6.7
:repackage failed: Unable to find a single main class from the following candidates [com.example.demo.DemoApplication, com.example.demo.service.MainService] -> [Help 1]
找到出错原因就好说了,错误提示里已经说明代码中存在不止一个主函数。并且已经在[]中把存在主函数的类标出来了,我们只需要把多余的主函数删除或者在pom文件中指明主函数即可。
解决办法
我这边是因为另一个主函数是无意中带进去的,所以把多余的主函数删掉即可。除了删除多余主函数外,我们还可以在pom文件中指定主函数。或者使用@SpringBootApplication注解都可以。
在pom文件中指定
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.5.9.RELEASE</version>
<configuration>
<mainClass>com.xx.xxx.startApp</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
使用@SpringBootApplication注解
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
这样也可以解决以上问题。
思考
为什么在IDEA中就能正常启动呢?
因为IDEA的配置里面显式指定了主函数。
PS:项目构建失败但是公司平台提示构建打包成功误导了我好长时间==
边栏推荐
- How to add a condition for an associated table in an SQL statement [null value required or not required]
- AI edge computing platform - beaglebone AI 64 introduction
- 集群方法同步执行框架 Suona
- (summary I) Halcon Foundation's target finding features + becoming a regular
- SWT/ANR问题--ANR/JE引发SWT
- Short video platform development, relying on drawerlayout to achieve side sliding menu effect
- 视觉特效,图片转成漫画功能
- Machine learning 10 belief Bayesian classifier
- 7_ Openresty installation
- Thread Detach
猜你喜欢

如何在智汀中實現智能鎖與燈、智能窗簾電機場景聯動?

How does ZABBIX configure alarm SMS? (alert SMS notification setting process)
![[2022] Jiangxi postgraduate mathematical modeling scheme and code](/img/f4/86b0dc2bd49c3a54c1e0538b31d458.png)
[2022] Jiangxi postgraduate mathematical modeling scheme and code

RestCloud ETL WebService数据同步到本地

My PMP learning test experience

SWT / anr problem - binder stuck

Focusing on green and low carbon, data center cooling has entered a new era of "intelligent cooling"
![Pytoch -- foundation refers to the north_ II. What high school students can understand [back propagation and gradient descent]](/img/6e/279dbb7a8d7a5ecd240de464c5b8b2.png)
Pytoch -- foundation refers to the north_ II. What high school students can understand [back propagation and gradient descent]

A preliminary understanding of operator overloading

Leetcode interview question 17.10 Main elements
随机推荐
The latest CSDN salary increase technology stack in 2022 overview of APP automated testing
SWT/ANR问题--AMS/WMS
Thread Detach
Small program cloud development -- wechat official account article collection
端口号和进程号的区别?
URLs and URIs
What is project management?
The image variables in the Halcon variable window are not displayed, and it is useless to restart the software and the computer
Comment réaliser la liaison entre la serrure intelligente et la lampe, la scène du moteur de rideau intelligent dans le timing intelligent?
JS anti shake and throttling
522. Longest special sequence II
在unity中使用jieba分词的方法
I want to know how to open a stock account? Is it safe to open an account online?
FL studio20.9 fruit software advanced Chinese edition electronic music arrangement
ANR问题的分析与解决思路
Some uses of Halcon array
MnasNet学习笔记
centos 安装多个版本的php并切换
Dell服务器重启iDRAC方法
十大劵商如何开户?还有,在线开户安全么?