如何将org.apache.poi添加到Karafa

时间:2016-06-07 15:11:05

标签: java apache-poi apache-karaf

如何在项目中添加依赖项? OSGI + POI 在执行时这段代码

import org.apache.poi.ss.usermodel.WorkbookFactory

Workbook wb = WorkbookFactory.create(originalStream);

执行此代码后,抛出错误

Method threw 'java.lang.ClassNotFoundException' exception.
org.apache.poi.ss.usermodel.WorkbookFactory not found by wrap_mvn_org.apache.poi_poi_3.11 [761]

我的pom.xml添加依赖

<dependency>
     <groupId>org.apache.poi</groupId>
     <artifactId>poi-ooxml-schemas</artifactId>
     <version>3.11</version>
</dependency>
<dependency>
      <groupId>org.apache.xmlbeans</groupId>
      <artifactId>xmlbeans</artifactId>
      <version>2.6.0</version>
</dependency>
<dependency>
      <groupId>org.apache.poi</groupId>
      <artifactId>ooxml-schemas</artifactId>
      <version>1.1</version>
</dependency>
<dependency>
      <groupId>org.apache.poi</groupId>
      <artifactId>poi</artifactId>
      <version>3.11</version>
</dependency>
<dependency>
      <groupId>org.apache.poi</groupId>
      <artifactId>poi-ooxml</artifactId>
      <version>3.11</version>
</dependency>

            <plugin> 
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>

            <version>${maven-bundle-plugin.version}</version>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                   <DynamicImport-Package>*</DynamicImport-Package>
                 </instructions>
           </configuration>
        </plugin>

安装bandle karaf:

bundle:install wrap:mvn:org.apache.poi/poi/3.11
bundle:install wrap:mvn:org.apache.poi/poi-ooxml/3.11
bundle:install wrap:mvn:org.apache.poi/poi-ooxml-schemas/3.11
bundle:install wrap:mvn:org.apache.poi/ooxml-schemas/1.1  

Karaf中的所有捆绑包都成功安装并运行

1 个答案:

答案 0 :(得分:1)

Alexandre Cartapanis你是对的

  
    
      

也许你应该使用servicemix提供的osi的poi包(org.apache.servicemix.bundles / org.apache.servicemix.bundles .poi / 3.14_1)

    
  

感谢所有人。