有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java maven从多个模块构建可执行jar

我有以下项目结构,并试图将我的整个项目编译成一个jar

---父POM ----主层——服务层——DTO层。我正在使用Maven Shade Plugin使用mvn package命令创建一个唯一的可执行jar文件,但我得到的是这样的编译错误

[INFO] core-data .......................................... FAILURE [  0.616 s]

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project core-data: Compilation failure: Compilation failure:

\BetRadar\core-data\src\main\java\com\zzilla\entities\sportEntities\Handball.java:[3,46] error: **package com.sportradar.sdk.feed.common.entities** does not exist
[ERROR] \BetRadar\core-data\src\main\java\com\zzilla\entities\sportEntities\Handball.java:[12,12] error: cannot find symbol

我将以下构建配置放在父pom中。在我的主模块层中,我有一个依赖于服务层的项目,它本身也依赖于核心数据(存储库)层。错误日志com中提到的包。运动雷达。sdk。喂养常见的实体存在于项目结构中包含的sdk jar文件中:

<dependency>
    <groupId>com.sportradar.sdk</groupId>
    <artifactId>sdk-parent</artifactId>
    <version>1.1.0.0</version>
    <scope>system</scope>
    <systemPath>${basedir}/src/sdk jar/sdk.jar</systemPath>
</dependency>

似乎maven对这种依赖性有些问题。我怎样才能达到预期的结果?POM中是否缺少关于依赖项声明的部分? 我的项目名

        <!-- download source code in Eclipse, best practice -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-eclipse-plugin</artifactId>
            <version>2.9</version>
            <configuration>
                <downloadSources>true</downloadSources>
                <downloadJavadocs>false</downloadJavadocs>
            </configuration>
        </plugin>


        <!-- Set a compiler level -->
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
        <source>${source.jdk.version}</source>
        <target>${source.jdk.version}</target>
        </configuration>
        </plugin>

        <!-- Maven Shade Plugin -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>2.3</version>
            <executions>
                <!-- Run shade goal on package phase -->
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <transformers>
                            <!-- add Main-Class to manifest file -->
                            <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                <mainClass>zzilla.Main</mainClass>
                            </transformer>
                        </transformers>
                    </configuration>
                </execution>
            </executions>
        </plugin>

    </plugins>
</build>

共 (0) 个答案