首页 > 解决方案 > 为什么 META-INF 文件夹是空的?

问题描述

没有 META-INF 文件对我来说非常重要,因为我使用的是 Swagger UI,它会将 META-INF 添加到资源处理程序中。

Pom 文件:

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.2.RELEASE</version>
        <relativePath/>
    </parent>
    <packaging>war</packaging>
    <properties>
        <java.version>1.8</java.version>
        ...
    </properties>
    <build>
        <plugins>
            <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>3.2.0</version>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>${maven-war-plugin.mainClass}</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <encoding>UTF-8</encoding>
                    <annotationProcessorPaths>
                        <annotationProcessorPath>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>${lombok.version}</version>
                        </annotationProcessorPath>
                        <annotationProcessorPath>
                            <groupId>org.hibernate</groupId>
                            <artifactId>hibernate-jpamodelgen</artifactId>
                            <version>${hibernate.version}</version>
                        </annotationProcessorPath>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>
        </plugins>
    </build>


这是我的src/main/resources文件夹:

resources
--application.properties
--logback--spring.xml

当我运行时mvn clean install,这就是我从目标文件夹中得到的全部内容:

target
--classes
--project-1.0-SNAPSHOT
--generated-sources
--generated-test-sources
--maven-archiver
--maven-status
--surefire-reports
--test-classes
--project-1.0-SNAPSHOT.war
--project-1.0-SNAPSHOT.war.original

我真的很困惑为什么我的清单文件没有被生成。我在里面检查了目标--project-1.0-SNAPSHOT,我看到了 2 个目录 META-INF 和 WEB-INF(除了其他生成的东西)。WEB-INF 包含所有的类、库和视图。META-INF 绝对是空的。

我检查了我的application.properties文件,没有看到任何改变资源路径的属性。

标签: javaspringmavenswagger-ui

解决方案


推荐阅读