car*_*tax 9 maven maven-tomcat-plugin
我的问题正是这个maven-shade插件用户面临的问题:
但我正在使用tomcat7-maven-plugin构建一个自运行的webapp.我最近切换了数据库驱动程序以使用Microsoft自己的驱动程序来实现JDBC4.现在我有问题,包括它作为我的exec-war目标中的extraDependency.这是相关部分pom.xml.
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<id>tomcat-run</id>
<goals>
<goal>exec-war-only</goal>
</goals>
<phase>package</phase>
<configuration>
<path>/oases</path>
<contextFile>applicationContext.xml</contextFile>
<extraDependencies>
<extraDependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</extraDependency>
</extraDependencies>
<excludes>
<exclude>META-INF/MSFTSIG.RSA</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
该项目构建正常,但maven不遵守该exclude指令,以便sqljdbc4 RSA文件包含在META-INF目录中.这意味着当我尝试运行我的exec-war jar文件时,我收到此错误.
Exception in thread "main" java.lang.SecurityException: Invalid
signature file digest for Manifest main attributes
Run Code Online (Sandbox Code Playgroud)
我已经阅读了代码,据我所知,插件已正确配置为排除sqljdbc4 META-INF文件.这是版本2.2的插件代码,这是我正在使用的.看起来这应该做我想要的.然而,exec-war jar仍包括META-INF/MSFTSIG.RSA
protected void extractJarToArchive( JarFile file, ArchiveOutputStream os, String[] excludes )
throws IOException
{
Enumeration<? extends JarEntry> entries = file.entries();
while ( entries.hasMoreElements() )
{
JarEntry j = entries.nextElement();
if ( excludes != null && excludes.length > 0 )
{
for ( String exclude : excludes )
{
if ( SelectorUtils.match( exclude, j.getName() ) )
{
continue;
}
}
}
if ( StringUtils.equalsIgnoreCase( j.getName(), "META-INF/MANIFEST.MF" ) )
{
continue;
}
os.putArchiveEntry( new JarArchiveEntry( j.getName() ) );
IOUtils.copy( file.getInputStream( j ), os );
os.closeArchiveEntry();
}
if ( file != null )
{
file.close();
}
}
}
Run Code Online (Sandbox Code Playgroud)
EDITS
您发布的代码AbstractExecWarMojo有一个错误:continue内部 for 循环中的代码没有任何效果。相反,它应该在外部 while 循环上继续,以便在exclude匹配时跳过放置存档条目,如下所示:
protected void extractJarToArchive( JarFile file, ArchiveOutputStream os, String[] excludes )
throws IOException
{
Enumeration<? extends JarEntry> entries = file.entries();
outer:
while ( entries.hasMoreElements() )
{
JarEntry j = entries.nextElement();
if ( excludes != null && excludes.length > 0 )
{
for ( String exclude : excludes )
{
if ( SelectorUtils.match( exclude, j.getName() ) )
{
continue outer;
}
}
}
if ( StringUtils.equalsIgnoreCase( j.getName(), "META-INF/MANIFEST.MF" ) )
{
continue;
}
os.putArchiveEntry( new JarArchiveEntry( j.getName() ) );
IOUtils.copy( file.getInputStream( j ), os );
os.closeArchiveEntry();
}
if ( file != null )
{
file.close();
}
}
}
Run Code Online (Sandbox Code Playgroud)
要解决项目中的此问题,您可以从源代码检出/修改/构建 tomcat7-maven-plugin。如果你这样做了,并且测试成功,那么如果你贡献了一个补丁那就太好了。我已经为此提出了问题。
| 归档时间: |
|
| 查看次数: |
808 次 |
| 最近记录: |