相关疑难解决方法(0)

有没有快速的方法从Jar/war中删除文件而无需提取jar并重新创建它?

所以我需要从jar/war文件中删除一个文件.我希望有类似"jar -d myjar.jar file_I_donot_need.txt"的内容

但是现在我从Linux命令行(不使用WinRAR/Winzip或Linux等价物)看到这样做的唯一方法就是

  • 做"jar -xvf"并解压缩
    完整的Jar文件
  • 删除我不需要的文件
  • 使用"jar -cvf"重新启动jar文件

请告诉我有一个较短的方法?

java linux jar

98
推荐指数
1
解决办法
8万
查看次数

如何为exec-war目标排除extraDependency META-INF文件?

我的问题正是这个maven-shade插件用户面临的问题:

如何从bundle中排除META-INF文件?

但我正在使用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

org.apache.tomcat.maven.plugin.tomcat7.run.AbstractExecWarMojo.java

protected void extractJarToArchive( JarFile file, ArchiveOutputStream os, String[] excludes )
    throws IOException
    {
        Enumeration<? extends JarEntry> entries = file.entries();
        while ( entries.hasMoreElements() )
        { …
Run Code Online (Sandbox Code Playgroud)

maven maven-tomcat-plugin

9
推荐指数
1
解决办法
808
查看次数

标签 统计

jar ×1

java ×1

linux ×1

maven ×1

maven-tomcat-plugin ×1