天天看點

maven karaf 4.0x中使用jetty部署web 應用;karaf 4.0 x離線使用

maven 打包karaf 4.0 x features

<dependency>
        <groupId>org.apache.karaf.features</groupId>
        <artifactId>framework</artifactId>
        <type>kar</type>
        <version>4.0.2</version>
    </dependency>
    <dependency>
        <groupId>org.apache.karaf.features</groupId>
        <artifactId>standard</artifactId>
        <classifier>features</classifier>
        <type>xml</type>
        <version>4.0.2</version>
    </dependency>
           

打包過程中調整,在bootFeatures配置需要安裝的feature

<plugins>
        <!-- if you want to include resources in the distribution -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.6</version>
            <executions>
                <execution>
                    <id>process-resources</id>
                    <goals>
                            <goal>resources</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <!-- karaf-maven-plugin will call both install-kar and instance-create-archive goals -->
        <plugin>
            <groupId>org.apache.karaf.tooling</groupId>
            <artifactId>karaf-maven-plugin</artifactId>
            <extensions>true</extensions>
             <version>4.0.2</version>
            <configuration>

                 <bootFeatures>
                  <feature>cxf-jaxrs</feature>
                   <feature>cxf-commands</feature>   
                   <feature>pax-war</feature>
                   <feature>pax-http-jetty</feature>
                   <feature>pax-http-whiteboard</feature>
                    <feature>wrap</feature>
                    <feature>aries-blueprint</feature>
                    <feature>shell</feature>
                    <feature>shell-compat</feature>
                    <feature>feature</feature>
                    <feature>jaas</feature>
                    <feature>ssh</feature>
                    <feature>management</feature>
                    <feature>bundle</feature>
                    <feature>config</feature>
                    <feature>deployer</feature>
                    <feature>diagnostic</feature>
                    <feature>feature</feature>
                    <feature>instance</feature>
                    <feature>kar</feature>
                    <feature>log</feature>
                    <feature>package</feature>
                    <feature>service</feature>
                    <feature>system</feature>
                </bootFeatures>

            </configuration>
        </plugin>
    </plugins> 
           

調整startup.properties

打包後,如果startup.properties中有過多的 啟動項,可以進行删減,feature相關的 啟動項都可以删掉,以免啟動過多的程式,影響啟動速度

在karaf 4.0x中使用jetty 不需要單獨安裝pax-web-features,karaf本身已經内嵌。