【问题标题】:Adding DevTools dependency gives error running spring boot application in STS添加 DevTools 依赖项会导致在 STS 中运行 Spring Boot 应用程序时出错
【发布时间】:2019-08-07 12:27:03
【问题描述】:

添加 DevTools 后,我遇到以下错误,导致我的应用程序无法在 STS 中运行。错误和我的pom.xml如下。

错误:

线程“主”java.lang.IllegalStateException 中的异常:未能 从 jar 的清单中读取 Class-Path 属性 文件:/C:/Users/Jahadul%20Rakib/.m2/repository/antlr/antlr/2.7.7/antlr-2.7.7.jar 在 org.springframework.boot.devtools.restart.ChangeableUrls.getUrlsFromClassPathOfJarManifestIfPossible(ChangeableUrls.java:132) 在 org.springframework.boot.devtools.restart.ChangeableUrls.fromClassLoader(ChangeableUrls.java:98) 在 org.springframework.boot.devtools.restart.DefaultRestartInitializer.getUrls(DefaultRestartInitializer.java:92) 在 org.springframework.boot.devtools.restart.DefaultRestartInitializer.getInitialUrls(DefaultRestartInitializer.java:56) 在 org.springframework.boot.devtools.restart.Restarter.(Restarter.java:142) 在 org.springframework.boot.devtools.restart.Restarter.initialize(Restarter.java:556) 在 org.springframework.boot.devtools.restart.RestartApplicationListener.onApplicationStartingEvent(RestartApplicationListener.java:76) 在 org.springframework.boot.devtools.restart.RestartApplicationListener.onApplicationEvent(RestartApplicationListener.java:50) 在 org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) 在 org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) 在 org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) 在 org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127) 在 org.springframework.boot.context.event.EventPublishingRunListener.starting(EventPublishingRunListener.java:69) 在 org.springframework.boot.SpringApplicationRunListeners.starting(SpringApplicationRunListeners.java:48) 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:302) 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) 在 com.book.BookShopApplication.main(BookShopApplication.java:33) 原因:java.util.zip.ZipException:无效的 LOC 标头(坏 签名) 在 java.util.zip.ZipFile.read(Native Method) 在 java.util.zip.ZipFile.access$1400(未知来源)在 java.util.zip.ZipFile$ZipFileInputStream.read(Unknown Source) at java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(未知来源) 在 java.util.zip.InflaterInputStream.read(Unknown Source) 在 sun.misc.IOUtils.readFully(未知来源)在 java.util.jar.JarFile.getBytes(未知来源)在 java.util.jar.JarFile.getManifestFromReference(未知来源)在 java.util.jar.JarFile.getManifest(未知来源)在 org.springframework.boot.devtools.restart.ChangeableUrls.getUrlsFromManifestClassPathAttribute(ChangeableUrls.java:153) 在 org.springframework.boot.devtools.restart.ChangeableUrls.getUrlsFromClassPathOfJarManifestIfPossible(ChangeableUrls.java:129) ... 17 更多

pom.xml

 <?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>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.3.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.rakib.springboot</groupId>
    <artifactId>book-shop</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>book-shop</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <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-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thymeleaf.extras</groupId>
            <artifactId>thymeleaf-extras-springsecurity4</artifactId>
            <version>3.0.4.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
        </dependency>

        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4.7</version>
        </dependency>
        <dependency>
            <groupId>org.antlr</groupId>
            <artifactId>antlr-complete</artifactId>
            <version>3.5.2</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional>
        </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>

【问题讨论】:

  • 您的依赖有问题,请尝试从您的 .m2/repository 中删除这些依赖。

标签: maven spring-boot devtools


【解决方案1】:

您的 .m2 存储库似乎已损坏依赖关系 antlr-2.7.7.jar 尝试 remove antlr-2.7.7.jar 并清理并重建您的项目。如果这没有帮助,那么删除 whole .m2 repository 肯定会对您有所帮助。


您可以在此处找到 .m2 存储库

C:/Users/Jahadul%20Rakib/.m2

【讨论】:

    猜你喜欢
    • 2020-03-05
    • 2016-10-18
    • 2014-05-08
    • 2019-02-09
    • 2020-12-12
    • 2015-12-28
    • 2018-02-25
    • 2017-06-24
    • 1970-01-01
    相关资源
    最近更新 更多