1

我在让 Maven 构建正常工作时遇到问题。它构建得很好,除了在 JAR 中找到的清单文件中的 Main-Class 不存在。

目前,我有一个父 POM,两个模块各有一个 POM。反应堆摘要显示所有三个构建都成功。

但是,当我尝试在其中一个模块中运行 jar 时,我被告知“不存在主要清单属性”。检查 jar 中清单文件的内容显示未设置 Main-Class:

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Built-By: user
Created-By: Apache Maven 3.3.9
Build-Jdk: 1.8.0_66

这是父 POM 的构建内容:

<build>

    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>${maven-compiler-plugin.version}</version>
            <configuration>
                <source>${java.version}</source>
                <target>${java.version}</target>
                <executable>${java.compiler}</executable>
                <verbose>${java.compiler.verbose}</verbose>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>${maven-javadoc-plugin.version}</version>
            <configuration>
                <quiet>${javadoc.quiet}</quiet>
            </configuration>
            <executions>
                <execution>
                    <id>attach-javadocs</id>
                    <phase>package</phase>
                    <configuration>
                        <additionalparam>-Xdoclint:none</additionalparam>
                    </configuration>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

    </plugins>
</build>

<modules>
    <module>ConsolidatedCustomerMasterEndpoint</module>
    <module>ConsolidatedCustomerMasterService</module>
</modules>

这是模块 POM 的构建内容:

   <build>
            <resources>
                <resource>
                    <directory>src/main/resources</directory>
                    <filtering>true</filtering>
                </resource>
            </resources>
            <pluginManagement>
                <plugins>
                    <plugin>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-maven-plugin</artifactId>
                        <version>${spring-boot.version}</version>
                        <configuration>
                            <mainClass>no.xyz.ccm.config.CcmApp</mainClass>
                            <classifier>jetty</classifier>
                            <requiresUnpack>
                                <dependency>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>CcmService</artifactId>
                                </dependency>
                            </requiresUnpack>
                            <addResources>false</addResources>
                        </configuration>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>repackage</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <version>${maven-build-helper-plugin.version}</version>
                        <executions>
                            <execution>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>add-source</goal>
                                </goals>
                                <configuration>
                                    <sources>
                                        <source>src/generated/java</source>
                                    </sources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-resources-plugin</artifactId>
                        <version>${maven-resources-plugin.version}</version>
                        <configuration>
                            <delimiters>
                                <delimiter>@</delimiter>
                            </delimiters>
                        </configuration>
                    </plugin>
                </plugins>
            </pluginManagement>
        </build>
4

0 回答 0