APPLICATION FAILED TO START 异常报错原因及解决方案
Posted 李三岁~
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了APPLICATION FAILED TO START 异常报错原因及解决方案相关的知识,希望对你有一定的参考价值。
文章目录
- 一、APPLICATION FAILED TO START 异常报错原因分析
- 二、端口号被占用(Port 8080 was already in use) 导致的 APPLICATION FAILED TO START
- 三、Mybatis 导致的 APPLICATION FAILED TO START
- 四、Knife4J 导致的 APPLICATION FAILED TO START
一、APPLICATION FAILED TO START 异常报错原因分析
1. 异常报错描述:
APPLICATION FAILED TO START 应用程序无法启动/应用程序启动失败
这个错误提示只是告诉了我们应用程序启动失败,可能造成的原因很多,而仅仅只是这个提示无法告诉我们具体的原因,我们需要根据具体的原因进行具体的分析。
二、端口号被占用(Port 8080 was already in use) 导致的 APPLICATION FAILED TO START
1. 详细描述:
1.1 详细描述1(对应案例1):
Description:
Web server failed to start. Port 8080 was already in use.
2. 异常报错信息案例:
2.1 案例1:
2.1.1 异常错误描述:
错误原因:端口号 8080 被占用 导致的应用程序启动失败
2.1.2 解决方案:
- 关闭对应端口号的应用程序(服务)
- 找到启动对应端口号的项目,直接关闭(如果找不到,可使用下面链接的解决办法)
- 端口号被占用解决办法(超详细)https://blog.csdn.net/weixin_46030002/article/details/126649348
- 修改要启动项目的端口号
此项目应该为 SpringBoot 项目,可以通过修改配置文件的方式修改该项目的端口号- application.properties
server.port=8090
- application.yml
server: port: 9000
- application.properties
三、Mybatis 导致的 APPLICATION FAILED TO START
1. 详细描述:
1.1 详细描述1(对应案例1):
Description:
Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded datasource could be configured.
2. 异常报错信息案例:
2.1 案例1:
2.1.1 异常错误描述:
错误原因:数据源没有配置导致的应用程序启动失败
2.1.2 解决方案(一):
解决思路:这里,我们只需要检查我们的配置文件是否添加了正确的数据源信息
-
application.properties(创建项目默认)
spring.datasource.url=jdbc:mysql://localhost:3306/demo_admin?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai spring.datasource.username=root spring.datasource.password=root
-
application.yml
spring: datasource: url: jdbc:mysql://localhost:3306/demo_admin?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai username: root password: root
2.1.3 解决方案(二):
当然如果我们不需要使用这个配置源,我们也可以忽略/排除这个数据源
我们可以在 SpringBoot
项目的启动类上添加 exclude
属性
// exclude= DataSourceAutoConfiguration.class 忽略数据源的自动配置
@SpringBootApplication(exclude= DataSourceAutoConfiguration.class)
public class MallOssApplication
public static void main(String[] args) SpringApplication.run(MallOssApplication.class, args);
四、Knife4J 导致的 APPLICATION FAILED TO START
1. 详细描述:
1.1 详细描述1(对应案例1):
Description:
Field openApiExtensionResolver in cn.cy.config.Knife4jConfiguration required a bean of type ‘com.github.xiaoymin.knife4j.spring.extension.OpenApiExtensionResolver’ that could not be found.
1.2 详细描述2(对应案例2):
Description:
Parameter 0 of constructor in com.github.xiaoymin.knife4j.spring.plugin.DynamicResponseModelReader required a bean of type ‘springfox.documentation.schema.TypeNameExtractor’ that could not be found.
2. 异常报错信息案例:
2.1 案例1:
2.1.1 异常错误描述:
错误原因:类
Knif4jConfiguration
中的openApiExtensionResolver
属性没有被注入
2.1.2 解决方案:
解决思路:这里,我们只需要检查我们的配置文件是否添加了正确的
knif4j
配置
-
application.properties(创建项目默认)
knife4j.enable=true
-
application.yml
#开启Knife4j的增强模式 knife4j: enable: true
2.2 案例2:
2.2.1 异常错误描述:
错误原因:类
DynamicResponseModelReader
因为没有无参构造方法所以没有被注入
2.2.2 解决方案:
解决思路:这里,我们只需要检查我们的配置类中是否添加了
@EnableSwagger2WebMvc
注解,或者检查是否添加了@ComponentScan("springfox.documentation.schema")
-
解决方案一:添加
@EnableSwagger2WebMvc
注解
-
解决方案二:添加
@ComponentScan("springfox.documentation.schema")
centos下git报错Failed to connect to repository : Command "git ls-remote -h HEAD" returned sta
Failed to connect to repository : Command "git ls-remote -h HEAD" returned status code 128:
stdout:
stderr: fatal: repository 'http://ytgit.chinasoft.cn/chinasoft/innerapi.git/' not found
# 通过在git 服务器上进行clone项目报错如下
# git clone http://ytgit.chinasoft.cn/chinasoft/innerapi.git
Cloning into 'innerapi'...
fatal: repository 'http://ytgit.chinasoft.cn/chinasoft/innerapi.git/' not found
# git clone git@ytgit.chinasoft.cn:chinasoft/innerapi.git
Cloning into 'innerapi'...
GitLab: The project you were looking for could not be found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
经过搜索发现是本地git配置和仓库里的 .git/config 不一致
# 远程仓库配置
# more maxserver/.git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = http://ytgit.chinasoft.cn/chinasoft/maxserver.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
本地配置:
# git config --list
user.password=chinasoft1234
user.email=chengjn@chinasoft.cn
credential.helper=store
# 修改本地配置后问题解决
[root@sz_yt_jenkins01_12_99 ~]# cat .gitconfig
[user]
#password = chinasoft1234
#email = chengjn@chinasoft.cn
[credential]
helper = store
[root@sz_yt_jenkins01_12_99 ~]# cat .git-credentials
http://yt_release_deployment:SgKHNzqV5gGDhXs@ytgit.chinasoft.cn
#http://chengjn:chinasoft1234@ytgit.chinasoft.cn
#http://chengjn:chinasoft1234@ytgit.chinasoft.cn
以上是关于APPLICATION FAILED TO START 异常报错原因及解决方案的主要内容,如果未能解决你的问题,请参考以下文章
centos下git报错Failed to connect to repository : Command "git ls-remote -h HEAD" returned sta
GTA4运行出现SecuLauncher:failed to start application
怎样解决电脑开机出现this application failed to start because it could not fi
Android Studio模拟器出错,提示Application Installation Failed, Installation failed with message Failed to es
Failed to load property source from location 'classpath:/application.properties'
docker起不来报错:Failed to start Docker Application Container Engine.