java.lang.NoClassDefFoundError: org/apache/poi/ss/usermodel/Row

前端 未结 1 1966
悲&欢浪女
悲&欢浪女 2021-01-23 12:08

I\'ve made a small application that reads from an excel (xls file) and displays the contents to a JTable. Everything is working fine in eclipse, yet when I create the jar file a

相关标签:
1条回答
  • 2021-01-23 12:19

    Probably you are getting this only when you are running your jar because the dependencies are not available/packaged inside of it.

    Try generating a "fat jar" (also known as uber-jar), it will package all your dependencies inside the jar:

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <finalName>YOUR_JAR_FINAL_NAME</finalName>
                </configuration>
            </plugin>
        </plugins>
    </build>
    

    Documentation related to the maven-shade-plugin can be found in here

    UPDATE: Since you are using a runnable jar file, you can follow this section of the documentation related to Executable Jars

    0 讨论(0)
提交回复
热议问题