JRebel没有在src / main / resources目录中监听或重新加载更改

时间:2014-08-30 15:20:43

标签: jrebel

JRebel没有在src / main / resources目录中监听或重新加载更改,因此读取此类文件会返回缓存和无效值。

这是正常的吗?

5 个答案:

答案 0 :(得分:5)

确保该目录列在随应用程序部署的 rebel.xml 配置文件中。如果您的rebel.xml是使用JRebel plugin for Maven生成的,那么只需确保指定您希望将资源目录包含在配置中:

<addResourcesDirToRebelXml>true</addResourcesDirToRebelXml>  

如果您正在使用IntelliJ IDEA,并且没有看到应用于资源的更改,那么您可能尚未将IDE配置为将资源目录中的文件复制到目标目录。或者将资源目录标记为“resources”目录(右键单击项目树中的文件夹 - &gt;将目录标记为...)

答案 1 :(得分:1)

如果您使用的是IntelliJ IDEA,请尝试&#34;制作项目&#34;在&#34; Build&#34;选项卡或按Ctrl + F9。

答案 2 :(得分:1)

我遇到了同样的问题,阅读手册后我发现了一个适合我的解决方案。

我正在使用Spring 3的JSF项目,使用netbeans并通过IDE运行jrebel

请注意,评论是我之前尝试过的事情,但这并不意味着无效。

这里重要的是在classpath中添加资源路径,并删除jrebel自动放入Web节点的链接标记。

rebel.xml:

<application generated-by="netbeans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns="http://www.zeroturnaround.com" 
    xsi:schemaLocation="http://www.zeroturnaround.com http://update.zeroturnaround.com/jrebel/rebel-2_1.xsd">

<classpath>
    <!--<dir name="/path_to_project_root/target/classes"></dir>-->
    <dirset dir="/path_to_project_root/">
        <include name="**/target/classes"/>
        <include name="**/src/main/resources"/>
    </dirset> 
    </classpath>

    <web>
    <!--<link target="/">-->
        <dir name="/path_to_project_root/src/main/webapp"></dir> 
        <dir name="/path_to_project_root/src/main/resources"></dir> 
    <!--</link>-->
    </web>

</application>

我也在pom.xml中配置了插件,将属性addResourcesDirToRebelXml设置为true

的pom.xml:

<plugin>
    <groupId>org.zeroturnaround</groupId>
    <artifactId>jrebel-maven-plugin</artifactId>
    <version>1.1.7</version>
    <configuration>
        <addResourcesDirToRebelXml>true</addResourcesDirToRebelXml>
    </configuration>
    <executions>
        <execution>
            <id>generate-rebel-xml</id>
            <phase>process-resources</phase>
            <goals>
                <goal>generate</goal>
            </goals>
        </execution>
    </executions>               
</plugin> 

来源:https://manuals.zeroturnaround.com/jrebel/standalone/advanced-config.html

答案 3 :(得分:1)

确保您的项目在eclipse中没有任何编译错误。

同时检查您的JDK合规性。我的版本错误,我的目标/类文件没有更新。

如果目标/班级内容未更新,则jrebel将不会看到任何更改。

答案 4 :(得分:0)

我用过类似的东西,它对我有用。 JRebel插件需要安装在IDEA上,或者可以在pom.xml中使用插件

注1:rebel.xml文件由IDEA上的JRebel插件自动生成到src / main / resources中,因此不需要将jrebel插件添加到pom.xml中

注2:不要忘记在路径中保持斜线,而不是反斜线! ;)

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com" xsi:schemaLocation="http://www.zeroturnaround.com http://update.zeroturnaround.com/jrebel/rebel-2_1.xsd">

  <classpath>
    <dir name="C:/myWorkspace/myWar/target/classes"></dir>
  </classpath>

  <web>
    <link target="/">
      <dir name="C:/myWorkspace/myWar/src/main/webapp"></dir>
    </link>
  </web>

</application>
相关问题