【问题标题】:Spring Boot 2.0.4 + Thymeleaf 3.0.9: Could not initialize class HTMLTemplateParserSpring Boot 2.0.4 + Thymeleaf 3.0.9:无法初始化类 HTMLTemplateParser
【发布时间】:2019-01-22 12:38:20
【问题描述】:

我正在尝试使用带有 Maven 和 Thymeleaf 的 Spring Boot 运行一个基本的 web 应用程序。

这是我的环境:

  • MacOS High Sierra 10.13.6(最新版本)
  • Java 1.8(应该兼容)
  • Spring Boot 2.0.4(使用 Maven 导入)
  • Thymeleaf(使用 Maven 导入)
  • 嵌入式Tomcat

我的问题是,当我尝试在嵌入式 Tomcat 网络服务器中运行我的演示应用程序时,我收到以下错误:

白标错误页面 此应用程序没有 /error 的显式映射,因此您将其视为后备。

2018 年 8 月 15 日星期三 17:03:07 CEST 出现意外错误 (类型=内部服务器错误,状态=500)。 org/attoparser/config/ParseConfiguration

检查控制台,这是异常堆栈跟踪:

java.lang.ClassNotFoundException: org.attoparser.config.ParseConfiguration 在 java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_60] 在 java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_60] 在 sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_60] 在 java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_60] 在 org.thymeleaf.templateparser.markup.HTMLTemplateParser.(HTMLTemplateParser.java:43) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE] 在 org.thymeleaf.engine.TemplateManager.(TemplateManager.java:117) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE] 在 org.thymeleaf.EngineConfiguration.initialize(EngineConfiguration.java:137) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE] 在 org.thymeleaf.TemplateEngine.initialize(TemplateEngine.java:341) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE] 在 org.thymeleaf.TemplateEngine.getConfiguration(TemplateEngine.java:406) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE] 在 org.thymeleaf.spring5.view.ThymeleafView.renderFragment(ThymeleafView.java:255) ~[thymeleaf-spring5-3.0.9.RELEASE.jar:3.0.9.RELEASE] 在 org.thymeleaf.spring5.view.ThymeleafView.render(ThymeleafView.java:187) ~[thymeleaf-spring5-3.0.9.RELEASE.jar:3.0.9.RELEASE] 在 org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1325) ~[spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在 org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1069) ~[spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在 org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1008) ~[spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在 org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925) ~[spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在 org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:974) ~[spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在 org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:866) ~[spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在 javax.servlet.http.HttpServlet.service(HttpServlet.java:635) ~[tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:851) ~[spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在 javax.servlet.http.HttpServlet.service(HttpServlet.java:742) ~[tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat-embed-websocket-8.5.32.jar:8.5.32] 在 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) ~[spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在 org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109) ~[spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在 org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93) ~[spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在 org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) ~[spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在 org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) ~[tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) [tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) [tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) [tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) [tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800) [tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:800) [tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1471) [tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-8.5.32.jar:8.5.32] 在 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_60] 在 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_60] 在 org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.5.32.jar:8.5.32] 在 java.lang.Thread.run(Thread.java:745) [na:1.8.0_60]

奇怪的是,如果我在发生此错误后尝试发送另一个 HTTP GET 请求(= 重新加载页面),我会收到另一个错误:

白标错误页面 此应用程序没有 /error 的显式映射,因此您将其视为后备。

2018 年 8 月 15 日星期三 16:52:35 CEST 出现意外错误 (类型=内部服务器错误,状态=500)。无法初始化类 org.thymeleaf.templateparser.markup.HTMLTemplateParser

这里也是这个错误的控制台输出:

java.lang.NoClassDefFoundError: 无法初始化类 org.thymeleaf.templateparser.markup.HTMLTemplateParser 在 org.thymeleaf.engine.TemplateManager.(TemplateManager.java:117) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE] 在 org.thymeleaf.EngineConfiguration.initialize(EngineConfiguration.java:137) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE] 在 org.thymeleaf.TemplateEngine.initialize(TemplateEngine.java:341) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE] 在 org.thymeleaf.TemplateEngine.getConfiguration(TemplateEngine.java:406) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE] 在 org.thymeleaf.spring5.view.ThymeleafView.renderFragment(ThymeleafView.java:255) ~[thymeleaf-spring5-3.0.9.RELEASE.jar:3.0.9.RELEASE] 在 org.thymeleaf.spring5.view.ThymeleafView.render(ThymeleafView.java:187) ~[thymeleaf-spring5-3.0.9.RELEASE.jar:3.0.9.RELEASE] 在 org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1325) ~[spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在 org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1069) ~[spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在 org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1008) ~[spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在 org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925) ~[spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在 org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:974) ~[spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在 org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:866) ~[spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在 javax.servlet.http.HttpServlet.service(HttpServlet.java:635) ~[tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:851) ~[spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在 javax.servlet.http.HttpServlet.service(HttpServlet.java:742) ~[tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat-embed-websocket-8.5.32.jar:8.5.32] 在 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) ~[spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在 org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109) ~[spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在 org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93) ~[spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在 org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) ~[spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在 org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) ~[tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) [tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) [tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) [tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) [tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800) [tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:800) [tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1471) [tomcat-embed-core-8.5.32.jar:8.5.32] 在 org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-8.5.32.jar:8.5.32] 在 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_60] 在 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_60] 在 org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.5.32.jar:8.5.32] 在 java.lang.Thread.run(Thread.java:745) [na:1.8.0_60]

这第二个错误是“稳定的”,这意味着如果我在发生此错误后重新加载页面,则会再次出现相同的错误。

webapp 的代码几乎是从使用旧 Spring Boot 版本 (1.4.2) 的本教程复制粘贴而来的。

https://www.mkyong.com/spring-boot/spring-boot-hello-world-example-thymeleaf/

我改变的只是 - Spring Boot 版本:从 1.4.2 到 2.0.4 - web 包:显然 Spring Boot 1.4.2 中嵌入了 web 包,而今天没有。 所以我在 Maven pom.xml 文件中添加了这个依赖:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

如果我使用 1.4.2 版本,系统工作正常,所以我认为这是我采取的“错误步骤”。 但是,我发现的所有最新教程都以这种方式使用这个 spring-boot-starter-web 包,并且它们都在我的环境中引发了这个错误。

所以我很困惑。

这是我的完整 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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>Demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</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-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

有什么想法吗?

【问题讨论】:

  • 我无法重现该问题,您确定只有这些更改吗?
  • 是的,POM 文件中的这些更改是我在整个项目中所做的唯一更改:( 它是否在您使用 Spring Boot 2.0.4 的环境中工作?
  • 是的,我刚刚运行它,使用 Apache Maven 3.3.9 版本和 java 版本“1.8.0_121”
  • 嗯,我使用的是 JDK 1.8.0_60。现在我更新了 JDK 1.8.0_181 但错误仍然存​​在。至于 Maven,我使用 3.5.4。你也在 MacOS 上吗?
  • 不,一个 GNU/Linux 发行版,您是使用 IDE 编译运行您的应用程序还是只是一个终端?

标签: java macos spring-boot web-applications thymeleaf


【解决方案1】:

好吧,虽然看起来很奇怪,但我已经自己解决了这个问题。 显然,这是由 Eclipse 和 Maven 下载和处理文件 attoparser/2.0.4.RELEASE/attoparser-2.0.4.RELEASE.jar 的方式引起的。 它可能已损坏。

不过我不太确定。

以下是我为解决此问题所遵循的步骤。

  • 由于可能是环境问题,首先我尝试将项目切换到 IntelliJ CE。
    问题没有解决(即使现在错误消息略有不同)。

  • 不知道该怎么办,我认为问题可能与 Spring Boot 版本 2.0.4 有关。所以我尝试在 pom.xml 文件中将 Spring Boot 依赖项从 2.0.4 版本更改为旧版本(例如 2.0.3、2.0.2 等)。
    在此更改之后,Webapp 甚至无法启动。 我只会得到 IllegalStateException: Failed to read Class-Path attribute from manifest for file attoparser/2.0.4.RELEASE/attoparser-2.0.4.RELEASE.jar*。
    这很奇怪:为什么项目要使用 attoparser 2.0.4(我相信它是 Spring Boot 2.0.4 的一部分),即使我专门将 Maven pom.xml 设置为使用另一个 Spring Boot 版本?

  • 我在网上发现可能是 Maven Cache 中的 attoparser jar 文件已损坏。所以我尝试使用 IntelliJ 命令使所有缓存无效,并重新导入所有 Maven 依赖项。 它没有解决问题。

  • 不知道该怎么做,我用sudo rm 手动删除了 attoparser.jar 文件并重新导入了所有依赖项。 这次成功了:webapp 在 Spring Boot 2.0.0 上运行顺畅。

  • 然后我尝试在 pom.xml 中切换到更新的 Spring Boot 版本,再次重新导入依赖项。这次我没有问题。

所以,我只能猜测 Maven 下载了一个损坏的 attoparser 2.0.4 jar,并且由于某些原因它既不能通过使缓存无效来摆脱它,也不能切换到其他 attoparser 版本。因此,通过手动删除它,我可能已经解锁了这种情况。不过,这似乎是一个非常牵强的解释。

所以我暂时让这个问题仍然悬而未决。如果有人对发生的事情有更清晰的了解(以及 Maven 的工作原理......),如果您能在这里分享,我将不胜感激。

编辑:好的,由于没有人回答,我将结束这个问题。 如果有人能更好地解释我遇到的问题,请写在这里:)

【讨论】:

    猜你喜欢
    • 2014-02-15
    • 2022-01-18
    • 2018-12-22
    • 2018-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-07
    • 2017-06-11
    相关资源
    最近更新 更多