How to continuously deploy changes in JSF project without restarting Tomcat?

最后都变了- 提交于 2020-06-09 04:39:27

问题


I have a JSF project in Eclipse. Now every time I make changes to the .xhtml files, I have to stop Tomcat server, and then start Tomcat server again. Is there any other way where I can continuously build and test my application without restarting the server every time I make changes?


回答1:


There are at least two changes you need to make when you need to develop a JSF project:

  1. Tell Eclipse to automatically publish changes by changing the Tomcat settings as follows (doubleclick Tomcat server entry in Servers view to get this screen):

    enter image description here

    It namely defaults to "Never publish automatically".


  2. Tell JSF that the webapp is currently in development mode by adding the following to web.xml:

    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    

    This will change some internal workings to make the developers easier such as disabling the Facelet cache and reloading resources. Don't forget to remove this when building a production release because this affects performance. This setting can alternatively also be set by JNDI.


The alternative is to migrate from the barebones Tomcat server to a normal JEE server such as WildFly, Payara, Liberty, etc. For them, the above described Eclipse setting is not necessary anymore and you can even live edit bean methods (on Tomcat, you'd still need to restart the whole server for them).




回答2:


facelets.REFRESH_PERIOD:
interval compiler checks for page changes – lower values useful during development

<context-param>  
<param-name>facelets.REFRESH_PERIOD</param-name>  
<param-value>2</param-value>  
</context-param>

      (or)

<context-param>  
<param-name>facelets.REFRESH_PERIOD</param-name>  
<param-value>1</param-value>  
</context-param>
  • you can set any one of the above.
    change in web.xml
  • set to -1 if you don't want to effect changes made.(default value)
  • check this link.

Edit: as @BalusC told, above will work for jsf 1.x, For jsf 2.X change publishing settings and javax.faces.PROJECT_STAGE in web.xml.



来源:https://stackoverflow.com/questions/11187040/how-to-continuously-deploy-changes-in-jsf-project-without-restarting-tomcat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!