1

我编写了一个非常简单(没有 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 应该是什么样的?越简单越好。

4

2 回答 2

2

我有类似的要求(只是 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>
于 2012-08-15T13:04:49.533 回答
1

这对我来说已经成功了(尽管我确实需要添加一个占位符 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>
于 2012-08-15T13:41:06.233 回答