how to make changes on a project and running it through IDE without deploying it on server
I want to know how I can make changes in my code and run it on se开发者_运维技巧rver directly from my eclipse IDE in place of converting my project every time to war file and deploy it on server.
I don't want to see my changes reflecting only by converting it to war file and deploying it every time on server.. can i see them on the fly directly through my eclipse IDE as soon as make some changes..
Plz help me i don't know exactly what to search on google .So seeking "SO" help.
Thanks in advance.
PS: Sorry My bad!!! I should have given more information... I am working on Spring Hibernate based project ...which is having only java files
You can use the Eclipse-WTP Plugin to handle your Web-Projects (http://www.eclipse.org/webtools). With this plugin you can create "dynamic web projects" which can deployed on a specified (Tomcat) server.
If you use maven and your project is structured like a maven-webapp(webapp-archetype), you can also use the m2eclipse-plugin to import your maven-project and run it on an server.
Following up on sjr's answer, the wicket quickstart archetype contains such a main class. Here it is:
Start.java (HEAD)
There is nothing wicket-specific about it, it can be used to run any Java webapp project
Copy it to src/test/java and execute it as a main class
you will need the following dependencies in your pom:
<dependency>
<groupId>org.eclipse.jetty.aggregate</groupId>
<artifactId>jetty-all-server</artifactId>
<version>7.3.0.v20110203</version>
<scope>provided</scope>
</dependency>
There are so many different ways to do this, but here's one approach that may work for you (it's hard to tell because you haven't been specific about your container environment):
In the main
method of a new Java application:
- create an instance of a servlet container (e.g. Jetty or Tomcat)
- register your application's servlets using the servlet container's API calls
- create the relevant URL mappings for your static resources
- start the HTTP server
Then, run this application in debug mode. You now have a mini environment running inside Eclipse.
Everything can't be reflected on the fly
- You can change images,javascript files,css such files on the fly.
Some files are there which are manipulated on the context initialization time, like(web.xml, spring conf files, and some other conf file ) So , You can't change them on the fly but you can change these and restart the server to see the effect.
Some Servlet and Java code needs to compile and you can change them on the fly if they were not loaded by classloader (You can't be 100% sure here)
You can use the HotSwap technologies through the WTP eclipse plug-in to see the effect of the your changed code without the need to redeploy the whole application to the application server. This link has a tutorial for how to setup the tomcat hot deploy using WTP eclipse plug-in .
But this HotSwap technologies has many limitations , for example , it only allows to change the method bodies but doesn't allow adding/removing classes ,fields , constructors , methods , annotations etc.And modification of the XML files and property files (eg web.xml , faces-config.xml ) cannot be reflected instantly .
JRebel can overcome these limitations but it is not free .It discuss the limitation of other alternatives free/open source here
精彩评论