Maven-部署文件目标

Maven-部署文件目标,maven,Maven,我有一个maven项目,其中一些xlsx文件是在项目运行阶段之后生成的。其他一些项目也使用这些excel表格。因此,我需要将这些excel工作表工件发布到远程本地存储库 我尝试了部署插件的部署文件目标。但是在repo中将excel表部署为jar之后,我尝试提取jar,我可以看到excel表被破坏了。Excel工作表转换为多个XML文件。(Sheet1.xml、Sheet2.xml.) Maven命令:- mvn清理部署:部署文件-Durl=file:///C:\repository-Dfile=

我有一个maven项目,其中一些xlsx文件是在项目运行阶段之后生成的。其他一些项目也使用这些excel表格。因此,我需要将这些excel工作表工件发布到远程本地存储库

我尝试了部署插件的部署文件目标。但是在repo中将excel表部署为jar之后,我尝试提取jar,我可以看到excel表被破坏了。Excel工作表转换为多个XML文件。(Sheet1.xml、Sheet2.xml.)

Maven命令:-

mvn清理部署:部署文件-Durl=file:///C:\repository-Dfile=Series.xlsx-DpomFile=seriesXL.pom

SeriesXL.pom:-

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.test.pjt</groupId>
  <artifactId>seriesXL</artifactId>
  <version>1.0</version>
  <packaging>jar</packaging>

 <build>
  <plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>2.3.1</version>
    <configuration>
        <includes>
            <include>*.xlsx</include>
        </includes>
    </configuration>
</plugin>
  </plugins>

</build> 


    <dependencies>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.6</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>3.6</version>
        </dependency>
    </dependencies>

</project>

4.0.0
com.test.pjt
系列XL
1
罐子
org.apache.maven.plugins
maven jar插件
2.3.1
*.xlsx
org.apache.poi
poi
3.6
org.apache.poi
poi ooxml
3.6

请帮我解决这个问题。感谢所有输入。

这是因为使用deploy file命令时,pom被忽略。您必须运行mvndeploy,以便调用maven jar插件(在包阶段默认调用)

通过您的命令,您将xslx直接部署到存储库中,我怀疑它是作为jar处理的,因此,如果您解压缩jar,您将获得xml(因为xlsx也只是一个打包文件,由各种xml文件组成)


我建议您阅读一些关于Maven生命周期等的文档()

微软正试图在其office套件中推出使用ZIP和XML的新文件格式。此方法将文件大小减少约50%

这意味着excel文件实际上是包含不同XML和其他元数据信息的打包文件

我已经做了一项工作来解决这个问题:

  • 生成excel工作表后,我使用
    java.util.zip.ZipEntry
    将该文件添加到一个zip(SeriesXL.zip)中

  • 然后使用命令部署zip文件

    mvn clean deploy:deploy-file -Durl=file:///C:\repository -Dfile=SeriesXL.zip -DgroupId=com.test.pjt -DartifactId=seriesXL -Dversion=1.0 -Dpackaging=jar
    
  • 我能够在本地存储库中成功地部署SeriesXL.jar,并且在提取jar的同时,我可以看到Excel工作表的原始版本,而不仅仅是XML文件包


    顺便说一句,谢谢邓尼的支持。

    谢谢你的回复。但我的项目需求是,首先构建项目,将pjt jar部署到nexus repo,然后运行单元测试,最后调用Main()方法。项目成功执行后,将动态生成excel工作表(其中包含一些pjt信息)。这些信息也应提供给其他项目。这就是为什么,我试图在nexus中单独手动发布excel工作表作为工件。我将包装方案用作“Jar”。是否可以创建一个jar,其中包含原始格式的excel工作表?以下命令可能会起作用:mvn deploy:deploy file-Durl=file:///C:\repository-Dfile=Series.xlsx-DgroupId=com.test.pjt-DartifactId=seriesXL-Dversion=1.0I尝试了上述部署文件目标,并能够创建jar文件。但在提取过程中,excel仍然损坏。提取日志:-C:\repository\com\test\pjt\seriesXL\1.0>jar-xvf seriesXL-1.0.jar膨胀:_rels/.rels膨胀:[内容类型].xml膨胀:docProps/app.xml膨胀:docProps/core.xml膨胀:xl/printerSettings/printerSettings 1.bin膨胀:xl/printerSettings/printerSettings 2.bin膨胀:xl/sharedStrings.xml膨胀:xl/theme/theme1.xml膨胀:xl/workbook.xml膨胀:xl/_rels/workbook.xml.rels膨胀:xl/worksheets/sheet1.xml充气:xl/worksheets/_-rels/sheet1.xml.rels充气:xl/worksheets/sheet2.xml充气:xl/worksheets/_-rels/sheet2.xml.rels充气:xl/worksheets/sheet3.xml充气:xl/worksheets/sheet4.xml充气:xl/worksheets/sheets/sheet5.xml