java—如何将依赖项包含到jar文件中(maven)

92dk7w1h  于 2021-07-26  发布在  Java
关注(0)|答案(0)|浏览(194)

我已经尝试了我在这里遇到的与这个主题有关的每一个解决方案,但是我仍然找不到一个解决方案。
在eclipse(springboot+maven)中运行我的项目时,一切都很顺利。我能够从api调用中看到一些json数据。我的目标是在cloudfoundry上部署这个项目,但是我经常遇到classnotfounderror(java)。下面是我的pom文件。
我尝试过将jar导出为可运行的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>

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题