spring - Tomcat 7 启动失败并出现 srpingboot
问题描述
我有一个尝试运行的 spring-boot 应用程序(Tomcat 7、Jdk 1.8、maven)(它不是嵌入式 tomcat),但遇到了几个问题,例如:
Exception in thread "restartedMain" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: java.lang.AbstractMethodError: org.springframework.boot.context.config.ConfigFileApplicationListener.supportsSourceType(Ljava/lang/Class;)Z
at org.springframework.context.event.GenericApplicationListenerAdapter.supportsSourceType(GenericApplicationListenerAdapter.java:79)
at org.springframework.context.event.AbstractApplicationEventMulticaster.supportsEvent(AbstractApplicationEventMulticaster.java:289)
at org.springframework.context.event.AbstractApplicationEventMulticaster.retrieveApplicationListeners(AbstractApplicationEventMulticaster.java:221)
at org.springframework.context.event.AbstractApplicationEventMulticaster.getApplicationListeners(AbstractApplicationEventMulticaster.java:192)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:128)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:75)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:347)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:306)
at ep.OWebApplicationInitializer.main(OWebApplicationInitializer.java:14)
怎么了 ?我的主要课程:
@SpringBootApplication
public class OWebApplicationInitializer extends SpringBootServletInitializer {
public static void main(String[] args) {
new SpringApplication(OWebApplicationInitializer.class).run(args);
}
}
我的 pom 就是这样:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
有人对这个问题有想法吗?
解决方案
您在类路径上的依赖项版本不匹配。
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
并使用Tomcat 8。
推荐阅读
- mysql - 无法从 VPS 连接到 MySQL 服务器,但可以从桌面连接
- laravel - Laravel - 验证消息未显示在刀片上
- node.js - 运行 Node.js 服务器时出现此错误是什么问题?
- postgresql - 在共享维度上组合多个事实表时,哪些 BI 工具可以轻松生成正确的查询?
- java - Spring Hateoas 调试 uriTemplate 不能为空
- sql - SQL:过滤连接表
- r - 安装时遇到问题。packag("BatchGetSymbols")
- xamarin - 如何在使用 NUnit 运行 Xamarin.UITest 时调试 Xamarin 代码
- java - Gatling 脚本给出错误并且未生成报告
- oracle - 使用字符数作为分隔符sql