How do I implement dynamic reloading in Spring (Netbeans)? - spring

I'm used to writing Grails applications where my view or controller changes are automatically redeployed on save. I'm now stringing together a Spring Web-
MVC application and I'd like the same feature.
I'm using Netbeans as an IDE, Gradle as a build tool and the spring-boot plugin at the moment. I remember some talk of people using Jetty as it's so quick to restart that dynamic class reloading / deployment is no longer necessary. I've heard others mention JRebel which I used to use a few years back. I'm sure there is a more modern, spring-supported / spring-standard way of doing it.
I'd also like to know if you recommend deploying as a WAR or as a standalone executable JAR with a lightweight built-in web server.
Recommendations appreciated.

A yet unsolved challenge
It turns out that the Netbeans Gradle plugin does not support "compile on save" out-of-the box - and this means that a Java Agent won't be able to pick up the changes. The author kelemen suggested one or two approaches around this. It's a non-negotiable for me, so I decided to switch IDE's to Eclipse (terrible Gradle support), then IntelliJ Idea - which is looking very promising.
Netbeans Gradle Author Comment: https://github.com/kelemen/netbeans-gradle-project/issues/183
Alternatively, there is Jrebel, which is claimed to be able to support this Netbeans / Gradle combination. I wasn't able to get it working easily using a trial of JRebel. The JRebel support guys are there to help, so if you're willing to pay the price, it's likely that their support team will solve your problems.
JRebel: http://zeroturnaround.com/software/jrebel/
If anything changes, please comment below...

Spring class reloading is supported by HotswapAgent as well. It is free alternative to JRebel.

Spring has their own agent as well: https://github.com/spring-projects/spring-loaded. While developing why not just use embedded Tomcat/Jetty provided by Spring Boot.

Related

How to enable spring support in IntelliJ Community Edition 2016.1.3

I have very good pure Java basic knowledge. As long as there are no XML config and no project management tools involved, I am very good.
The things that really confused me are the project management tools, e.g.: Maven, Gradle.
I am learning Spring, and it is so confusing to me since it involves many XML files and there is no clear explanation for it.
I am learning Spring from this set of video tutorials, Lecture 6
Spring "Hello World".
I couldn't get a Spring hello world done because it requires a xxxxx.xml file to config the beans (Java object). To generate the XML files, I need to generate an XML file using a plugin on IntelliJ 2016.
The question is I can't find the plugin to generate a XML file for the bean by following this official tutorial. There is no such plugin called " Spring Support".
What should I do to generate the beans.xml? (The file to manage beans for Spring)
You can't enable Spring support with IntelliJ community Edition, it only available with paying version (Ultimate).
However, you can create the .xml file manually and CE version also supports it (a little bit).
To working with Spring or J2EE, you should get familiar with build tools like Maven, Gradle (or Ant in some special case). The concept is simple and you can get it easily from the official website (https://maven.apache.org/ - http://gradle.org/).
For Spring, if you are not familiar with creating a .xml file, you can use Java configuration instead or move to use Spring-boot to forget this configuration file (almost).
However, at first, I think you should get the basic concept of Spring and try to work well with .xml files configure. It'll be helpful in the future when you work with it deeply.
Let's take things one by one:
Your problem understanding builds management tools like maven and gradle. Try these links for tutorials: Maven in 5 Minutes, gradle is very advance build automation tool with continuous Integration features, you can find a good comparison between gradle and maven here.
If you are confused about spring to try this book: Spring in Action 3rd Edition (4th Edition is also available, I recommend 3rd edition as you will be able to link XML to annotations.)
You do not need any tool to generate XML files. Copy a sample spring configuration file from the internet, remove unwanted elements and write your own beans.
The Spring support plugin is a feature of IntelliJ IDEA Ultimate, which is a commercial IDE. It's not available in the free Community Edition.
You don't need any plugin to generate the beans.xml file; you can write it manually in the source code editor.
For Spring support, did you try "Spring Assistant" plugin ?
https://plugins.jetbrains.com/plugin/10229-spring-assistant
Good part it is it has active development.
Edit on Aug 21, 2020:
Seems like this plugin has no more active development. Its last release was in 2018 April.
No need to worry. We sill have some good news :-)
Its Github repository is here. We can clone the repo and make necessary changes what ever we specifically need.
I know you are asking about IntelliJ Idea but as it is a commercial tool, you should pay to let you use its plugins. Another way is using "Spring Tools for Eclipse" which is a great environment to develop Spring applications. But you need to be familiar with eclipse.
It can be downloaded from:
Spring Tools 4 for Eclipse

Downloading Spring Jars without using Maven

How do you download Spring Framework jars if you can't stand Maven or any of the other build management tools. From what I can tell it seems you have to spend many frustrating hours on Google to find out how to do this. I thought Spring was supposed to be easy. All I'm trying to do is to write a simple Hello World application using Eclipse and Tomcat. Why is it so difficult with Spring 3?
go there
http://repo.spring.io/release/org/springframework/spring/
you can see all versions, like old school
Why can't you stand Maven? I like Maven, but I really like Gradle.
Either way, if you only build with your IDE, you can't automate your build (so no chance at continuous integration/delivery), and it's tough to integrate new members of your team. Specifically with this question about Spring dependencies, it is a lot easier to automate management of transitive dependencies rather than download them all yourself--and figuring out which new jars to download by tracing through one NoClassDefFoundError after another.
I think the Spring guys can't imagine why anyone would want to endure all these downsides. But it's your project and you should do what you think is right.
So if you must, grab the jars starting with this one from Maven Central yourself and have some fun.
That's funny. It seems everyone wants you to use a dependency management tool. You can always browse a maven repository and download the parts you need:
http://mvnrepository.com/artifact/org.springframework

How to get started with Server Side - Java - Spring Framework

I'm very new to server side programming, and I want to develop something by using java and Spring framework. I'm working in Android technology for the last two years and I'm very much familiar with Java and Eclipse IDE.
Can anyone provide me links to some useful tutorials and examples?
Which IDE will be more suitable for me? Eclipse or Netbeans?
Thanks in advance...
I think Eclipse is more suitable, Because you already know about Eclipse(Eclipse is used for android projects).
http://static.springsource.org/spring/docs/3.0.0.RELEASE/spring-framework-reference/html
http://static.springsource.org/docs/Spring-MVC-step-by-step/
It's a very vague question but I'll give you my opinion:
Learn Java EE - this includes:
JSP/JSF
Servlets
Web
EJB 3
Build an application using these technologies and only after you familiarize yourself with it, only then start using spring. Spring is using a lot of theses technologies behind the scenes and it is important to understand what is going on
Regarding eclipse vs netbeans - I'm a huge fan of eclipse and i think it is a great tool however netbeans has better integration with Glassfish (sun/oracle application server) and better GUI tools. so it is really a matter of taste.
As for web/application servers:
Tomcat is a great server to start with, but since it is a web server it does not support EJB.
For using EJB you'll need an application server like Jboss or glassfish.
I'd start with tomcat and then move to glassfish.
What IDEs are you used to? I recommend that you use STS - Spring Tool Suite, which is an Eclipse based IDE maintained by SpringSource. Alternatively, the IntelliJ IDEA Ultimate also provide good support for Spring projects.

Hard time on learning Java EE - mostly installing and testing stuff

Its quite a while since I started learning Java EE (I come from Rails world).
I'd like to test create a simple blog to test these:
- Hibernate, JPA
- Spring with MVC
- JSF and routing
- Struts 2
- Eclipse and local test (modify, reload, check changes)
- Tomcat, Jboss or Jetty
- An administration area (Session)
- Maven
I've a basic knowledge of each of those but as soon as I spend tons of time installing stuff and, somehow, I manage to resolve all inconveniences there is ALWAYS something that goes wrong (installation, tutorial obsolete, should I work with Spring IDE, MyEclipse, Jboss Application Server or regular Eclipse?, tons of random errors, each tutorial asking for random dependencies, each showcase).
QUESTION
How do you create quickly a startup project with these components?
You go with some Maven archetype? If so which one?
What I'd like is something I can download or build equipped out of the box with all above mentioned components. To name a few:
- railswizard.org, youvegotrails.com, railsboost.com/templates/new
SIDE QUESTION
Currently I'm following this great series, can you suggest some more like this:
- http://www.youtube.com/user/koushks?feature=gb_p13n_ch_rec
All the above components in a single project? That makes no sense; Spring MVC, Struts 2, and JSF would rarely be combined in the same project.
Each web framework has demo applications, what's wrong with those? There are archetypes for at least some combinations, although I'm not sure it's not better to put them together yourself.
Without knowing what kind of issues/errors you're getting, it's impossible to help. Maven should be taking care of most/all dependency issues. You shouldn't be spending much time installing anything by hand except maybe an app container.
IMO you're better off asking specific, actionable questions, and start with each specific technology and build up an application, rather than trying to integrate everything at once--a sure recipe for frustration.
For starting with a simple Java EE application, a good point to start is just downloading a Java EE 6 implementation.
Those are offered by various parties, which might be confusing at first. It's however just like there isn't the One and Only C compiler, but there are many and they all compile the same standard C.
For Java EE 6, obvious choices are GlassFish 3.1.2, JBoss AS 7.1, TomEE. (just pick one, at this stage it doesn't matter much which one you'll use).
Java EE 6 is a full stack solution. It's a single download and you don't necessarily need to install any other libraries. It comes with an MVC framework (JSF), an ORM solution (JPA), dependency injection (CDI), business logic support (EJB) and then some.
As for the IDE, NetBeans has a particular good default integration for GlassFish (can even be downloaded as one bundle), but for Eclipse it's not that difficult either. You need to download the Java EE edition of Eclipse and after starting it, go to Help -> Eclipse Marketplace, search for "GlassFish" and install the "GlassFish Server Plugin".
See also Minimal 3-tier Java EE app, without any XML config for a very minimal example to get started and JSF 2.0 tutorial with Eclipse and Glassfish for a very detailed one including instructions how to exactly setup the IDE.
What I'd like is something I can download or build equipped out of the box with all above mentioned components. To name a few:
http://appfuse.org/display/APF/Home
Appfuse will take you through the initial setup of a maven built spring based web application with hibernate included.
If you come from the rails world you might also look into Spring Roo which tries to borrow from Ruby i'm told. The primary focus of roo is to stand up all of the technology you've listed above quickly.

How to have Eclipse Scala-IDE + Spring-IDE plugins working together?

According to http://www.assembla.com/wiki/show/scala-ide/Troubleshooting in order to have the Scala Eclipse plugin to work with eclipse 3.5 you must desintall your Spring-IDE pluging since the latter deactive the JDT Weaving. I had to do so.
Do you know any effective way to circumvent this, I'm an active Spring developer, for obvious reasons I also want to incorporate the Scala-IDE to my environment.
The best place for questions like this is the Scala IDE user mailing list.

Resources