Maven 如何排除exec war目标的依赖性META-INF文件?
我的问题正是maven shade插件用户面临的问题: 但我正在使用tomcat7 maven插件构建一个自我运行的Web应用程序。我最近将数据库驱动程序改为使用微软自己的驱动程序,该驱动程序实现了JDBC4。现在我有一些问题,包括在我的exec war目标中将它作为一个外部依赖。以下是Maven 如何排除exec war目标的依赖性META-INF文件?,maven,maven-tomcat-plugin,Maven,Maven Tomcat Plugin,我的问题正是maven shade插件用户面临的问题: 但我正在使用tomcat7 maven插件构建一个自我运行的Web应用程序。我最近将数据库驱动程序改为使用微软自己的驱动程序,该驱动程序实现了JDBC4。现在我有一些问题,包括在我的exec war目标中将它作为一个外部依赖。以下是pom.xml的相关部分 org.apache.tomcat.maven 一种解决方法是使用依赖项jar 您为AbstractExecWarMojo发布的代码有一个bug:内部for循环中的continue
pom.xml
的相关部分
org.apache.tomcat.maven
一种解决方法是使用依赖项jar
您为AbstractExecWarMojo
发布的代码有一个bug:内部for循环中的continue
没有任何效果。相反,它应该在外部while循环上继续,以便在匹配排除时跳过放置存档项,如下所示:
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();
}
}
}
protectedvoid extractJarToArchive(JarFile文件,ArchiveOutputStream操作系统,字符串[]不包括在内)
抛出IOException
{
列举
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();
}
}
}