【问题标题】:How to add a path to a directory with an external dll in maven如何在maven中使用外部dll添加目录的路径
【发布时间】:2020-05-26 23:22:33
【问题描述】:

我在 intellij IDEA 中添加了带有 dll 的目录的路径:文件 -> 项目结构 -> 项目设置 -> 库,它显示为名称“lib”,类“E:\project...\libs” . 如果我使用想法运行,那么一切正常。 构建 jar 文件后,我运行并得到一个异常:java.lang.UnsatisfiedLinkError: Unable to load library 'MyDll.dll': Native library (win32-x86-64/MyDll.dll) not found in resource path。

如何使用 spring-boot-maven-plugin 配置 pom 文件,以便 dll 的路径在类路径中?

    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>

            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>

【问题讨论】:

    标签: java maven


    【解决方案1】:

    你必须添加一个系统依赖,例如:

    <dependency>
        <groupId>com.me</groupId>
        <artifactId>mydep</artifactId>
        <version>1.0</version>
        <scope>system</scope>
        <systemPath>${basedir}/lib/mydep-1.0.jar</systemPath>
    </dependency>
    

    但不建议这样做,您应该将您的依赖项发布到像 nexus 这样的存储库中

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-16
      • 2013-07-16
      • 2016-06-22
      • 1970-01-01
      • 1970-01-01
      • 2019-09-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多