Maven Shade Plugin + MsSQL JDBC -> 即时 JNI 错误 - 无效的签名文件清单

use*_*094 3 java sql sql-server jdbc maven

在我开始使用 MsSQL JDBC 之前,我的 Maven shade 插件运行良好

当我将 MsSql 添加到 pom.xml 并且我想运行该应用程序时,出现错误

错误:发生 JNI 错误,请检查您的安装并重试。

线程“main”中的异常java lang SecurityException

Manifest 主要属性的无效签名文件摘要

有什么建议我该如何解决?然而,Main 类是空的,只有一个简单的 main 方法。

 <build>
        <plugins>            

          <!-- Maven Shade Plugin -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.4.3</version>
                <executions>
                    <!-- Run shade goal on package phase -->
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <!-- add Main-Class to manifest file -->
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>mdb.Main</mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>    

        </plugins>
 </build>

 <dependencies>

        <dependency>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>mssql-jdbc</artifactId>
            <version>6.2.2.jre7</version>
        </dependency>                 

 </dependencies>

</project>
Run Code Online (Sandbox Code Playgroud)

use*_*094 7

<configuration>                                                                 
                            <filters>

                            <filter>
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>META-INF/*.SF</exclude>
                                        <exclude>META-INF/*.DSA</exclude>
                                        <exclude>META-INF/*.RSA</exclude>
                                    </excludes>
                                </filter>

                        </filters>                            
</configuration>
Run Code Online (Sandbox Code Playgroud)