我写了一个非常简单(没有java文件)的war文件,我希望将其部署到servicemix。它具有以下目录结构:
.
|-src
|-main
|-webapp
|-css
|-js
|-WEB-INF
\-web.xml
\-index.html
\-pom.xml
我可以使用以下命令将其部署到ServiceMix中运行的jetty容器中:
>install war:file:///<Fully qualified war location>?Webapp-Context=<Application name>
>osgi:start <Bundle id>
>http://localhost:8181/<Application name>/index.html
我更喜欢的是热部署,就像我对其他捆绑包一样。 pom.xml应该是什么样的?越简越好。
答案 0 :(得分: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>
答案 1 :(得分: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>