如何解决尝试创建可运行的JAR时,Maven构建失败[无法创建程序集:添加文件集时出错]
我已经编写了使用jdbc连接到数据库的代码,我正在使用 openJDK11.0.2 和 mssql JDBC驱动程序8.4.0 x64 。
连接类型是Windows身份验证,下面是我使用的依赖项
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>8.4.0.jre11</version>
</dependency>
当我完成MAVEN BUILD时,构建成功,并且我使用 java -jar testJava.jar 执行了JAR。 代码运行完美,我尝试执行的查询已执行。
但是我必须将该JAR交付给客户,他们将在他们的末端执行JAR,因此我尝试在我朋友的系统上执行我的JAR,但错误地指出mssql_jdbc_auth.dll
丢失了>
Exception in thread "main" com.microsoft.sqlserver.jdbc.sqlServerException: This driver is not configured for integrated authentication
作为一种变通方法,如果我将 mssql_jdbc_auth.dll 粘贴到jdk_ / bin /中,则可以使我的jar正常工作,但是效率不高。
我想使用代码或其他方式将这个DLL运送并指向我的jar中,所以我寻找了该DLL的maven依赖性,
我找到了一个
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc_auth</artifactId>
<version>8.4.0.x64</version>
<type>dll</type>
</dependency>
当我保存pom.xml时,依赖项已下载到 .m2 文件夹中,然后我尝试进行Maven构建我的项目,但它给我抛出了错误
Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5:single (default-cli) on project egain-identity-management-tool: Failed to create assembly: Error adding file-set for 'com.microsoft.sqlserver:mssql-jdbc_auth:dll:8.4.0.x64' to archive: Error adding archived file-set. PlexusIoResourceCollection not found for: C:\Users\Administrator\.m2\repository\com\microsoft\sqlserver\mssql-jdbc_auth\8.4.0.x64\mssql-jdbc_auth-8.4.0.x64.dll: No such archiver: 'dll'.
基本上是说即使存在DLL也找不到。
是因为我正在使用openJDK11吗?我只需要提供一个JAR,即可在其他人的计算机上执行JDBC操作,而无需移动任何文件或任何手动安排。
请提出一种方法。
//更新
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.testJava.demoProj.Consoletool</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
//这是我的POM.XML
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.demo.export</groupId>
<artifactId>demo-management-tool</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo-management-tool</name>
<url>http://maven.apache.org</url>
<!-- <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> -->
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.microsoft.graph</groupId>
<artifactId>microsoft-graph</artifactId>
<version>1.9.0</version>
</dependency>
<dependency>
<groupId>com.microsoft.graph</groupId>
<artifactId>microsoft-graph-core</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.microsoft.graph</groupId>
<artifactId>microsoft-graph-auth</artifactId>
<version>0.2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>args4j</groupId>
<artifactId>args4j</artifactId>
<version>2.0.10</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.13.3</version>
</dependency>
<dependency>
<groupId>com.egain.reporting</groupId>
<artifactId>egain-reporting-core</artifactId>
<version>2.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>8.4.0.jre11</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc_auth</artifactId>
<version>8.4.0.x64</version>
<type>dll</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.testJava.demoProj.Consoletool</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>allow-snapshots</id>
<activation><activeByDefault>true</activeByDefault></activation>
<repositories>
<repository>
<id>snapshots-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
</profile>
</profiles>
</project>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。