当前位置:网站首页>记一次服务部署失败问题排查
记一次服务部署失败问题排查
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:项目构建失败但是公司平台提示构建打包成功误导了我好长时间==
边栏推荐
- URLs and URIs
- AI 边缘计算平台 - BeagleBone AI 64 简介
- SQL语句关联表 如何添加关联表的条件 [需要null值或不需要null值]
- 【做题打卡】集成每日5题分享(第一期)
- @The difference between configurationproperties and @value
- 十大劵商如何开户?还有,在线开户安全么?
- Gartner研究:在中国,混合云的采用已成为主流趋势
- DenseNet网络论文学习笔记
- (translation) reasons why real-time inline verification is easier for users to make mistakes
- How do I open an account on my mobile phone? Also, is it safe to open an account online?
猜你喜欢

Gartner研究:在中国,混合云的采用已成为主流趋势

centos 安装多个版本的php并切换

Ernie-gram, 显式、完备的 n-gram 掩码语言模型,实现了显式的 n-gram 语义单元知识建模。

AI 边缘计算平台 - BeagleBone AI 64 简介

The latest wechat iPad protocol code obtains official account authorization, etc
![How to add a condition for an associated table in an SQL statement [null value required or not required]](/img/91/0efbc13597be4dba5b9cf4e8644e35.png)
How to add a condition for an associated table in an SQL statement [null value required or not required]

Rocketqa: cross batch negatives, de noised hard negative sampling and data augmentation

Ernie gram, an explicit and complete n-gram mask language model, implements explicit n-gram semantic unit knowledge modeling.

RestCloud ETL WebService数据同步到本地

Xception学习笔记
随机推荐
如果我在北京,到哪里开户比较好?另外,手机开户安全么?
The latest CSDN salary increase technology stack in 2022 overview of APP automated testing
Alphabet-Rearrange-Inator 3000(字典树自定义排序)
基于OPENCV和图像减法的PCB缺陷检测
Pulsar theme compression
SWT/ANR问题--Dump时间过长导致的SWT
機器學習10-信念貝葉斯分類器
LabVIEW calculates the camera image sensor resolution and lens focal length
halcon数组的一些使用
Machine learning 10 belief Bayesian classifier
How to add a condition for an associated table in an SQL statement [null value required or not required]
Ernie-gram, 显式、完备的 n-gram 掩码语言模型,实现了显式的 n-gram 语义单元知识建模。
What are the top ten securities companies? In addition, is it safe to open an account online now?
PMP是什麼?
Pytorch —— 基礎指北_貳 高中生都能看懂的[反向傳播和梯度下降]
How to realize the scene linkage of intelligent lock, lamp and intelligent curtain motor in zhiting?
详解数据治理知识体系
Pytorch —— 基础指北_贰 高中生都能看懂的[反向传播和梯度下降]
Objects and object variables
nacos配置中心使用教程