如何将依赖项包含到 JAR 文件 (Maven) 中

问题描述

我已经尝试了在这里遇到的与此主题相关的所有解决方案,但仍然无法找到解决方案。

在 Eclipse (Spring Boot + Maven) 中运行我的项目时,一切运行顺利。我能够从 API 调用中看到一些 JSON 数据。我的目标是在 CloudFoundry 上部署这个项目,但我经常收到 ClassNotFound 错误 (Java)。下面是我的 POM 文件

我尝试导出为 Runnable JAR 并通过命令行运行该 jar,但我也收到 NoClassFound 错误

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.5</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.intel</groupId>
    <artifactId>EDM</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>EDM</name>
    <description>EDM Library</description>
    <properties>
        <java.version>11</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web-services</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        
<!-- Mentor Dependencies -->
        
        <dependency>
            <groupId>com.mentor.datafusion.oi</groupId>
            <artifactId>com.mentor.datafusion.oi</artifactId>
            <version>1.0.0</version>
        </dependency>
        
        <dependency>
            <groupId>com.mentor.dms.ui</groupId>
            <artifactId>com.mentor.dms.ui</artifactId>
            <version>1.0.0</version>
        </dependency>        
       
        <dependency>
            <groupId>com.mentor.dms.xml.importexport</groupId>
            <artifactId>com.mentor.dms.xml.importexport</artifactId>
            <version>1.0.0</version>
        </dependency>
        
        <dependency>
            <groupId>dfo</groupId>
            <artifactId>dfo</artifactId>
            <version>1.0.0</version>
        </dependency>        

        <dependency>
            <groupId>dfutils</groupId>
            <artifactId>dfutils</artifactId>
            <version>1.0.0</version>
        </dependency>    

        <dependency>
            <groupId>com.mentor.datafusion.dfo.is3</groupId>
            <artifactId>com.mentor.datafusion.dfo.is3</artifactId>
            <version>1.0.0</version>
        </dependency>
                  

        <dependency>
            <groupId>com.mentor.is3.edm.login.api</groupId>
            <artifactId>com.mentor.is3.edm.login.api</artifactId>
            <version>1.0.0</version>
        </dependency>
        
        <dependency>
            <groupId>com.mentor.datafusion.dfo.is3.api</groupId>
            <artifactId>com.mentor.datafusion.dfo.is3.api</artifactId>
            <version>1.0.0</version>
        </dependency>        
        
        <dependency>
            <groupId>apache-logging-log4j</groupId>
            <artifactId>apache-logging-log4j</artifactId>
            <version>1.0.0</version>
        </dependency>  
        
           
    </dependencies>
    

    <build>
        <plugins>
        <plugin>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-maven-plugin</artifactId>
          <executions>
            <execution>
              <goals>
                <goal>repackage</goal>
              </goals>
              <configuration>
                <classifier>spring-boot</classifier>
                <mainClass>com.intel.EDM.EdmApplication</mainClass>
              </configuration>
            </execution>
          </executions>
          </plugin>
        </plugins>
    </build>

</project>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)