【问题标题】:Exporting dependency dll to resulting war将依赖 dll 导出到产生的战争
【发布时间】:2015-08-24 15:28:44
【问题描述】:

我有一个使用 jMUPdf 库作为外部依赖项的 Java Web 项目。由于我无法在任何公共 maven 存储库中找到 jMUPdf,我尝试使用 install-file 将它安装到我的本地 m2 存储库

jMUPdf 使用 jmupdf.jar 和依赖的 jmupdf64.dll,所以我这样做了:

mvn install:install-file -Dfile=jmupdf.jar -DgroupId=jmupdf -DartifactId=jmupdf -Dversion=0.4.1 -Dpackaging=jar

mvn install:install-file -Dfile=jmupdf64.dll -DgroupId=jmupdf -DartifactId=jmupdfdll64 -Dversion=0.4.1 -Dpackaging=dll

我可以在本地 m2 存储库中看到这两个库。

这是我的 pom.xml 的摘录

    <dependency>
        <groupId>jmupdf</groupId>
        <artifactId>jmupdfdll64</artifactId>
        <version>0.4.1</version>
        <scope>runtime</scope>
        <type>dll</type>
    </dependency>
    <dependency>
        <groupId>jmupdf</groupId>
        <artifactId>jmupdf</artifactId>
        <version>0.4.1</version>
    </dependency>

但是:编译我的项目(生成一个 war 文件)后,我只在 \WEB-INF\lib 中看到 jmupdf.jar 并且缺少 DLL。这当然是关于缺少 jmupdf64.dll 的运行时异常的原因

如何确保 dll 是生成的 war 文件的一部分?

编辑:...并且它也将被正确部署(例如到我的 Tomcat 上的 webapps/MYAPP/WEB-INF/lib 中)?

【问题讨论】:

  • 您可以在这里找到解决方案:stackoverflow.com/questions/1611357/…;考虑到 dll 的使用仅限于系统加载
  • 嗯,我看不出这对我有什么帮助。在我的情况下,应该将 DLL 打包到 war 中,然后(在 Tomcat 部署中)也被提取到 webapps 文件夹 /WEB-INF/lib 以便可用
  • 这就是我的意思:我认为该库不能在那个地方使用,除非应用程序通过 JNI 提供自己的加载机制。我可能错了……
  • @devnull69 ...你有没有找到答案?在war文件中包含一个dll?谢谢:)

标签: java dll maven-2


【解决方案1】:

这是我对使用 ms-jdbc 的集成安全性需求的简单解决方案...

    <dependencies>
    <dependency>
        <groupId>com.microsoft.sqlserver</groupId>
        <artifactId>mssql-jdbc_auth</artifactId>
        <version>8.4.1.x64</version>
        <type>dll</type>
        <scope>runtime</scope>
    </dependency>

    <dependency>
        <groupId>com.microsoft.sqlserver</groupId>
        <artifactId>mssql-jdbc</artifactId>
        <version>8.4.1.jre14</version>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>3.1.1</version>
            <executions>
                <execution>
                    <id>copy-dependencies</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <excludeScope>provided</excludeScope>
                        <includeTypes>dll</includeTypes>
                        <overWriteIfNewer>true</overWriteIfNewer>
                        <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/lib</outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-08-23
    • 2016-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多