JRebel 在OSGI環境中的使用

1.安裝JRebel破解版

2.在IDEA中安裝JRebel Plugin

3.在項目中增加rebel.xml

<plugin>
                <groupId>org.zeroturnaround</groupId>
                <artifactId>jrebel-maven-plugin</artifactId>
                <version>1.1.5</version>
                <executions>
                    <execution>
                        <id>generate-rebel-xml</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <!--<rebelXmlDirectory>${basedir}/src/main/webapp/WEB-INF/classes</rebelXmlDirectory>-->
                    <rebelXmlDirectory>${basedir}/src/main/resources</rebelXmlDirectory>
                    <!-- 指定生成的jrebel.xml放在哪裏,
                要求放在web應用的 classpath下 -->
                </configuration>
            </plugin>


4.在POM中配置JRebel的啓動



<plugin>
            <groupId>org.ops4j</groupId>
            <artifactId>maven-pax-plugin</artifactId>
            <version>1.5</version>
            <configuration>
                <!--
                                                         | some example Pax-Runner settings
                                                        -->
                <!--<args>file://${basedir}/pax-runner-args.txt</args>-->
                <provision>
                    <!--<param>-platform=felix</param>-->
                    <param>--vmOptions=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 -noverify -javaagent:D:\JavaTools\Jrebel\jrebel.jar  -Drebel.log=true</param>
                    <!--equinox-->
                    <param>--platform=equinox</param>
                    <!--<param>-clean</param>-->
                    <!--是否更新cache-->
                    <!--<param>-clean=true</param>-->
                    <!--<parm>-usePersistedState = false</parm>-->
                    <!--<parm>-workingDirectory=target/runner</parm>-->
                    <!--<parm>reference:file:${basedir}/tp-report/target/tp-report-1.0-SNAPSHOT</parm>-->
                    <!--<param>mvn:org.osgi/org.osgi.core/4.2.0@1</param>
                                <param>mvn:org.osgi/org.osgi.compendium/4.2.0@1</param>-->
                    <param>--log=debug</param>
                    <param>--bundleStartLevel=2</param>
                    <!--<param>-profiles=compendium,web,war,</param>-->
                    <!--Knopflerfish-->
                    <!--<param>-platform=kf</param>-->
                </provision>
            </configuration>
            <executions>
                <!--
                                                         | uncomment to auto-generate IDE files
                                                        <execution>
                                                          <id>ide-support</id>
                                                          <goals>
                                                            <goal>eclipse</goal>
                                                          </goals>
                                                        </execution>
                                                        -->
            </executions>
        </plugin>

 目前,這種方式下JRebel可以檢測到class的變化,但是不知道爲什麼,還是無法實現類的自動更新,需要在console手工輸入stop BundleID以及start BundleID命令,纔會更新類。

也嘗試了資源文件的更新,發現資源文件無法實現自動更新。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章