刚刚启动了一个简单的项目,当使用mvn spring-boot:build-image命令运行一个带有简单索引页的Docker容器进行构建时,我得到了以下错误。
不确定这是Tomcat还是Spring的问题?我也尝试了一个没有Undertow的构建,但响应相同。
在网上找不到任何类似的问题。此外,注意到它在Intellij中启动时运行良好,只有在停靠时才会失败。
silenceisgrand | /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
silenceisgrand | ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
silenceisgrand | \\/ ___)| |_)| | | | | || (_| | ) ) ) )
silenceisgrand | ' |____| .__|_| |_|_| |_\__, | / / / /
silenceisgrand | =========|_|==============|___/=/_/_/_/
silenceisgrand | :: Spring Boot :: (v2.3.2.RELEASE)
silenceisgrand |
silenceisgrand | 2020-11-09 09:01:15,366 INFO [main] org.springframework.boot.StartupInfoLogger: Starting SilenceisgrandApplication v0.0.1 on fd30e9598f54 with PID 1 (/workspace/BOOT-INF/classes started by cnb in /workspace)
silenceisgrand | 2020-11-09 09:01:15,367 INFO [main] org.springframework.boot.SpringApplication: The following profiles are active: h2o
silenceisgrand | 2020-11-09 09:01:15,723 INFO [main] org.springframework.data.repository.config.RepositoryConfigurationDelegate: Bootstrapping Spring Data JPA repositories in DEFERRED mode.
silenceisgrand | 2020-11-09 09:01:15,758 INFO [main] org.springframework.data.repository.config.RepositoryConfigurationDelegate: Finished Spring Data repository scanning in 29ms. Found 2 JPA repository interfaces.
silenceisgrand | 2020-11-09 09:01:16,037 WARN [main] org.springframework.context.support.AbstractApplicationContext: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is java.lang.NoSuchMethodError: 'org.apache.coyote.ProtocolHandler org.apache.coyote.ProtocolHandler.create(java.lang.String, boolean)'
silenceisgrand | 2020-11-09 09:01:16,044 INFO [main] org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener:
silenceisgrand |
silenceisgrand | Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
silenceisgrand | 2020-11-09 09:01:16,045 ERROR [main] org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter:
silenceisgrand |
silenceisgrand | ***************************
silenceisgrand | APPLICATION FAILED TO START
silenceisgrand | ***************************
silenceisgrand |
silenceisgrand | Description:
silenceisgrand |
silenceisgrand | An attempt was made to call a method that does not exist. The attempt was made from the following location:
silenceisgrand |
silenceisgrand | org.apache.catalina.connector.Connector.<init>(Connector.java:87)
silenceisgrand |
silenceisgrand | The following method did not exist:
silenceisgrand |
silenceisgrand | 'org.apache.coyote.ProtocolHandler org.apache.coyote.ProtocolHandler.create(java.lang.String, boolean)'
silenceisgrand |
silenceisgrand | The method's class, org.apache.coyote.ProtocolHandler, is available from the following locations:
silenceisgrand |
silenceisgrand | jar:file:/workspace/BOOT-INF/lib/tomcat-coyote-10.0.0-M8.jar!/org/apache/coyote/ProtocolHandler.class
silenceisgrand | jar:file:/workspace/BOOT-INF/lib/tomcat-embed-core-9.0.37.jar!/org/apache/coyote/ProtocolHandler.class
silenceisgrand |
silenceisgrand | The class hierarchy was loaded from the following locations:
silenceisgrand |
silenceisgrand | org.apache.coyote.ProtocolHandler: file:/workspace/BOOT-INF/lib/tomcat-coyote-10.0.0-M8.jar
silenceisgrand |
silenceisgrand |
silenceisgrand | Action:
silenceisgrand |
silenceisgrand | Correct the classpath of your application so that it contains a single, compatible version of org.apache.coyote.ProtocolHandler而pom看起来像这样;
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.silenceisgrand</groupId>
<artifactId>silenceisgrand</artifactId>
<version>0.0.1</version>
<name>silenceisgrand</name>
<description>The core silenceisgrand.com site</description>
<properties>
<java.version>11</java.version>
<webjars-bootstrap.version>4.5.3</webjars-bootstrap.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<version>5.4.0</version>
<scope>test</scope>
</dependency>
<!-- Undertow; replacing Tomcat -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
<version>2.3.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- webjars -->
<dependency>
<groupId>org.webjars</groupId>
<artifactId>webjars-locator-core</artifactId>
<version>0.46</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>3.5.1</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery-ui</artifactId>
<version>1.12.1</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>${webjars-bootstrap.version}</version>
</dependency>
<!-- Hamcrest -->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
<!-- Thymeleaf java8time extras -->
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-java8time</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>发布于 2020-11-09 23:42:58
除了我混淆了版本之外,maven还在跟我开玩笑,拒绝使用2.3.5版本的Besides,说没有这样的版本。最后,我必须首先清理项目,然后删除maven满意的Intellij缓存,在重新构建镜像后,它现在运行得很好。
https://stackoverflow.com/questions/64748759
复制相似问题