【问题标题】:Deploying simple war as OSGi bundle in ServiceMix在 ServiceMix 中将简单的战争部署为 OSGi 包
【发布时间】:2012-08-11 16:30:26
【问题描述】:

我编写了一个非常简单(没有 java 文件)的 war 文件,我希望将其部署到 servicemix。目录结构如下:

.
|-src
  |-main
    |-webapp
      |-css
      |-js
      |-WEB-INF
        \-web.xml
      \-index.html
\-pom.xml

我可以使用以下命令将它部署到在 ServiceMix 中运行的码头容器:

>install war:file:///<Fully qualified war location>?Webapp-Context=<Application name>
>osgi:start <Bundle id>
>http://localhost:8181/<Application name>/index.html

我更喜欢像使用其他捆绑包一样进行热部署。 pom.xml 应该是什么样的?越简单越好。

【问题讨论】:

    标签: maven osgi war apache-servicemix


    【解决方案1】:

    我有类似的要求(只是 Karaf,而不是 ServiceMix)。我的看起来像这样:

    编辑:请参阅 ben1729 对附加捆绑插件配置的回答。我忘记了那部分,因为它在我所有模块的父 pom.xml 中。

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <archive>
                        <!-- add the generated manifest to the war -->
                        <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                    </archive>
                    <overlays>
                      <overlay>
                        <!-- empty groupId/artifactId represents the current build -->
                          <excludes>
                              <exclude>*</exclude>
                          </excludes>
                      </overlay>
                    </overlays>
                </configuration>
            </plugin>
    
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <configuration>
                    <instructions>
                        <Web-ContextPath>/base/url</Web-ContextPath>
                    </instructions>
                </configuration>
            </plugin>
        </plugins>
    

    【讨论】:

      【解决方案2】:

      这对我来说已经成功了(尽管我确实需要添加一个占位符 java 文件以确保生成目标/类):

      <plugins>
          <plugin>
              <artifactId>maven-war-plugin</artifactId>
              <configuration>
                  <archive>
                      <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                  </archive>
              </configuration>
          </plugin>
          <plugin>
              <groupId>org.apache.felix</groupId>
              <artifactId>maven-bundle-plugin</artifactId>
              <executions>
                  <execution>
                      <id>bundle-manifest</id>
                      <phase>process-classes</phase>
                      <goals>
                          <goal>manifest</goal>
                      </goals>
                  </execution>
              </executions>
              <configuration>
                  <supportedProjectTypes>
                      <supportedProjectType>jar</supportedProjectType>
                      <supportedProjectType>bundle</supportedProjectType>
                      <supportedProjectType>war</supportedProjectType>
                  </supportedProjectTypes>
                  <instructions>
                      <Bundle-Version>${pom.version}</Bundle-Version>
                      <Webapp-Context>webclient</Webapp-Context>
                      <_include>-osgi.bnd</_include>
                  </instructions>
              </configuration>
          </plugin>
      </plugins>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-09-20
        • 2010-10-25
        • 1970-01-01
        • 2012-06-26
        • 1970-01-01
        • 2011-07-09
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多