Live debugging a Spring boot project in eclipse - eclipse

I am trying to create a Spring boot based MVC application using eclipse.
I created a starter template from spring's starter website and i have imported the maven package into eclipse.
I created a controller and a view and I am able to run the application by going to "debug as" or "run as" and selecting Java Application and then selecting the spring boot application main method from the list.
However with this approach, Eclipse does not seem to auto build my changes in my java classes nor the changes in my template views. (I use Thymeleaf btw) on the fly even though "auto build" is switched on in eclipse.
This forces me to stop the application in eclipse and re run the application for every small change i make and its very difficult.
Is this the only way on eclipse or is there a better way for eclipse would auto build the java and template files on the way so that I can code and debug simultaneously.

Eclipse is most likely compiling because that's what Eclipse does, but maybe you need to install the dev tools so that you get live reloading enabled.

Related

Type of Eclipse project for sample Spring project

In a tutorial at http://static.springsource.org/docs/Spring-MVC-step-by-step/part1.html Spring guys didn't say which Eclipse project they choose to create this sample application. Project icon has S symbol over it, so this isn't a Java project (marked with J symbol).
However, it doesn't look like a Dynamic Web project either.
Could you please explain that S symbol and say which project type is it?
They are using the Spring Eclipse plugin (either that, or they are using the Springsource Tool Suite IDE, based on Eclipse)
With this plugin, a dynamic web project should get you the 'S' you are looking for.
The S just means that the Spring nature is active (and it's either Spring IDE or SpringSource Tool Suite). In Eclipse-speak, I guess you should generate a dynamic web project, but it would be better to generate a Maven Project and import that into Eclipse (then Eclipse will automatically set the correct project type).

Gwt and eclipse with jetty for production mode

Is there a standard easy way to launch Jetty from eclipse for the production mode?
I followed the instructions at http://code.google.com/webtoolkit/usingeclipse.html to setup a new project using gwt and eclipse.
The hosted (debug) mode seems to be already configured to work properly and involves one click in eclipse using "Debug as".
I would like to configure "Run as" to run the production mode in jetty. Is there a good tutorial on the standard way to set this up?
You have to compile your GWT-project before you can "Run As". It's the button with a red box and "G" on it.
Since GWT compiles to java script you don't need jetty if you don't have server-side logic... anyway, in a normal scenario you'll have some server interaction, BUT you're not sticked to jetty; tomcat or other server side technology could be used.
You can deploy the compiled JS to a web server and the server side logic to tomcat, jboss, jetty... even you could interact with php at the server.
Deployment to Google AppEngine is another option, a natural option if you use the eclipse plugin since it's tightly integrated with it.
In eclipse, Jetty is no more than a java process started like any normal java main.
Go to [Run]->[Run Configurations]->[Web Application]->[Your GWT Project] and you'll see a normal java main exec config.
Look at the [Main Class] option -> this is the embeded jetty ..or at
the [VM arguments] for the JVM
The ?gwt.codesvr= param in the URL only instruct the browser plugin to interact with the eclipse plugin embeded jetty in a way that only the modified code is re-compiled to JS and sent to the browser.
If you do not use the ?gwt.codesvr= probabilly you'll have to recompile all the project every time you change a single line of code.
I recommend you to clearly separate the compiled-to-js code and the server side code in different eclipse projects.
I also run the embeded jetty only for the client-side code; the server side code is run in tomcat.
That way I have a clear separation of layers at the time I can debug client-side GWT code and server-side java code.

slight url mismatch while publishing java 6 maven webapp to tomcat from netbeans

Honestly I've started this small maven webapp using eclipse 3.6 (STS) and i found it so complicated that i had to switch to netbeans.I really wanted to use eclipse but these are reality on the ground.So at the end of everything I'll like to have an eclipse version of the same project. thanks
I set up the maven webapp using the embedded archetype, and use cargo plugin to take care of the deployment.basically there is only hello world index.jsp in the project.after picking pom configuration here and there my pom finally is like this .
while it started publishing after i restart the IDE, it's publishing to http://localhost:8080/ but for me I'm expecting it at http://localhost:8080/mvnTestWebap
so here are my questions
Question 1 : How can i correct that?
Question 2 : I believe my pom is tied to netbeans too much, how can i achieve the publishing to tomcat result but having a portable pom?Can anyone suggest a rewrite that can run on eclipse?
Question 3 : what correspond to netbeans "run" in eclipse?
probably by some deployment descriptor editing.
don't really understand the point. by default netbeans uses it's own embedded IDE way of deployment. That's not creating a pom tied to netbeans in any way. You can use that in eclipse or IDE or command line to build the project. The deployment part of the web app is specific to the server being used and the IDE being used.
You can also tell netbeans to execute your cargo plugin on executing the Run/Debug/Profile action (bypassing the netbeans default behaviour)
run basically performs a redeploy of the app on the server of choice. There has to be an equivalent on eclipse.

How to redeploy the web app using the Eclipse IDE

Im new to Eclipse. I use Tomcat as my run time server, but every time I modified the jsp pages, Eclipse was still displaying the older one. Just wondering how to redeploy the application so the changes can be reflected.
Eclipse: Eclipse IDE for Java EE Developers 1.2.1.20090918-0703
Tomcat: Tomcat 6.0
Thanks
Doubleclick the server instance in question in the Servers view to open its configuration. Now, in the right top you should see a section called Publishing. Open it to verify and configure autopublishing settings.
Eclipse should do that automatically for you.
Otherwise, on the Servers view (Menu Window->Show View->Servers), you can right click on your Tomcat instance and hit "Publish" or "Restart"
Make sure you have the "JST Server Adapters" ("Web, XML and Java EE Development category") feature installed.
Eclipse's publishing functionality requries the project to be a "web project", and in some cases requires additional configurations.
Go to Windows > Preferences > Server > Runtime environments and add your tomcat
Either try using publishing, or (better I think) use the FileSync plugin. There you can tell which folders from your project should be copied (live) to what directory on your machine (the tomcat/webapps/yourapp). With a little more effort the filesync configuration can be made machine independent (only using one parameter as TOMCAT_ROOT), in case you want to check-in the project to a repository where others will use it.
Get the Tomcat plugin. It was nice because you can install Tomcat on your system and then associate your web app with that instance of Tomcat. The plugin will let you stop/start Tomcat and define a server such that when you do a build it knows how to deploy the changes. There may be some newer plugin but the Tomcat plugin worked for me and was fairly simple to install and use. Here is a page from IBM on using Eclipse and Tomcat. Inside that page it points you to the following: http://www.ibm.com/developerworks/opensource/library/os-eclipse-tomcat/

Can't get compile on save / hot deploy feature to work with maven based webapp in eclipse or netbeans

So our new webapp project is based on maven. I'm really liking the dependency management and IDE agnostic approach but I'm having problems with compilation and debugging.
Here's how I would currently get a clean copy of the project working
Check out the main project from SVN
Open the project in IDE (I've tried in eclipse 3.4 and netbeans 6.7)
The IDE will automatically open two subprojects one being the webapp, the other being a supporting utils jar.
From the command line I run mvn war:inplace on the webapp module which builds a working copy of the webapp with all dependencies in WEB-INF/lib/
This then runs fine but whenever I change a java class I have to clean and build / reload the app context.
I've googled high and low but no one seems to be complaining about this so I guess there must be something really obvious I'm missing. How is everyone else handling incremental compilation and hot deploy with maven?
To clarify all I'm looking for is the replicate the behavior I used to have before maven where I could make simple changes to java classes and they would be instantaneously compiled and hot deployed to a running webapp. I don't need anything fancy like jRebel etc I just want the new tool to give me the same functionality I enjoyed with my old tools.
If you can use mvn jetty:run it will read the classes and resources directly from the project. Using Maven2 Eclipse plugin and running the server embedded in Eclipse has auto-publishing, which gets you there in the end, although it's slower. And JRebel starting with 2.0 (as you may know) can map the Maven module directly to the deployed application, so you get instant build and redeploy. Those are the only solutions I know of.
Netbeans should support it out of the box. Though, there remains a bug related to this: http://netbeans.org/bugzilla/show_bug.cgi?id=177230
In-place deployment works for me with Netbeans 7.0.1 and Tomcat 6.0.x if I use Tomcat 7.0.x in-place deployment doesn't work. Tomcat always copies application to $CATALINA_HOME/temp :(