Maven assembly has no package associations

I'm having problems using Maven. I have an Apache Flink project and want to run it on my server. Locally, it works fine, but on the server it fails with an error:

java.lang.NoClassDefFoundError: org/apache/flink/examples/java/ml/util/LinearRegressionData

In my Java project, I imported a class with

import org.apache.flink.examples.java.ml.util.LinearRegressionData;

And I used the correct class when importing:

enter image description here

After the build, I looked at the Jar file. The following classes were included:

enter image description here

The folder / util / is completely missing. My dependency section in the pom file is as follows:

<dependencies>
    <dependency>
        <groupId>org.apache.flink</groupId>
        <artifactId>flink-java</artifactId>
        <version>0.9.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.flink</groupId>
        <artifactId>flink-streaming-core</artifactId>
        <version>0.9.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.flink</groupId>
        <artifactId>flink-clients</artifactId>
        <version>0.9.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.flink</groupId>
        <artifactId>flink-table</artifactId>
        <version>0.9.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.flink</groupId>
        <artifactId>flink-runtime</artifactId>
        <version>0.9.0</version>
    </dependency>
</dependencies>

When I saw the package organization in the repository located at https://github.com/apache/flink/tree/release-0.9 , I thought that it would be possible to add the following lines for the transition:

    <dependency>
        <groupId>org.apache.flink</groupId>
        <artifactId>flink-examples</artifactId>
        <version>0.9.0</version>
    </dependency>

. Maven , , . , Maven . ?

+4
1

ML :

 <dependency>
    <groupId>org.apache.flink</groupId>
    <artifactId>flink-java-examples</artifactId>
    <version>0.9.0</version>
</dependency>

flink-examples pom; jar. jar? maven-jar-plugin? mvn package mvn install .

maven-jar-plugin , , <include>. . : https://maven.apache.org/plugins/maven-jar-plugin/examples/include-exclude.html

:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <configuration>
        <archive>
            <manifestEntries>
                <Main-Class>org.apache.flink.examples.java.ml.LinearRegression</Main-Class>
            </manifestEntries>
        </archive>

        <includes>
                <include>org/apache/flink/examples/java/ml/*.class</include>
                <include>org/apache/flink/examples/java/ml/util/*.class</include>
        </includes>
    </configuration>
</plugin>

https://github.com/apache/flink/blob/master/flink-examples/flink-java-examples/pom.xml

"" , maven-dependency-plugin

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.9</version><!--$NO-MVN-MAN-VER$-->
    <executions>
        <execution>
            <id>unpack</id>
            <phase>prepare-package</phase>
            <goals>
                <goal>unpack</goal>
            </goals>
            <configuration>
                <artifactItems>
                    <artifactItem>
                        <groupId>org.apache.flink</groupId>
                        <artifactId>flink-java-examples</artifactId>
                        <version>0.9.0</version>
                        <type>jar</type>
                        <overWrite>false</overWrite>
                        <outputDirectory>${project.build.directory}/classes</outputDirectory>
                    </artifactItem>
                </artifactItems>
            </configuration>
        </execution>
    </executions>
</plugin>
+3

All Articles