One of the best ways to get started with Broadleaf is to import the Heat Clinic into your favorite Java IDE. This will make editing code easier and also give you the ability to hook up a debugger to inspect code execution paths. You might not want to tie the execution of the Heat Clinic to the lifecycle of your IDE and instead run it from the command line. See the docs on running the Heat Clinic from your CLI.
We recommend completing the running the Heat Clinic from your CLI tutorial prior to completing this tutorial.
If you don't already have it, download the latest version of Eclipse Mars IDE for Java EE Developers. We recommend using Eclipse Mars SR2 (the latest).
While this tutorial is written with the assumption of Eclipse Mars and that is what we officially recommend, Eclipse Luna will likely also work as most of the setup tasks should be the same. The only exception is that you might have to manually install the
m2eclipseplugin from the Eclipse Marketplace
Once you have Eclipse installed, you should be sitting at a blank workspace that looks like this:
Once Eclipse is downloaded and installed (or if you are using an existing Eclipse installation), you should verify that you have a Java 8 JDK.
Open the Eclipse Preferences pane and navigate to Java -> Installed JREs. You should see an entry for Java SE 8 in the list:
In the above example, I have a few different installed JREs installed, but Java SE 8 is on the list and is the default JDK (Java 8 does not need to be the default JDK, just has to be in the list).
If you do not see Java SE 8 in the list, then you need to let Eclipse know about this JDK. Hit the 'Add...' button on the right of the 'Installed JREs' preferences pane. You should now be presented with this:
In the 'JRE home' input, put the environment variable for
JAVA_HOME that you set up in the running the Heat Clinic from your CLI tutorial. After adding the path you should see the JRE system libraries appear below:
Now you are all set to import the Heat Clinic into your workspace!
Now you need to import the Heat Clinic demo site into your workspace from the location that we saved the project to when we downloaded it.
It might take a bit to complete as Eclipse downloads all of the Maven dependencies necessary for Broadleaf. You will know it is done importing by activity on the bottom-right corner of your screen. If you cloned the project from GitHub, you might also see an 'Auto share git projects' dialog box as well.
Once the import process has finished, your workspace should look like this:
You should have 4 projects in your installation:
Now that the project is imported, right-click on the root project (which should be called DemoSite or ecommerce-website) and go to Maven -> Install:
This will fully compile and build the Heat Clinic application. Once this is completed, you now have 2 options:
In order to properly organize these projects within Eclipse, we highly recommend splitting out the projects into distinct working sets. Since the "Maven parent" project (that just contains a root
pom.xml without much else) also contains all of the subprojects (admin, core, site), this means you will get duplicates if you try to do things like open resource. You can see this if you type
cmd+shift+r (on OSX) or
ctrl+shift+r (on Windows) and then type
ProductController in the popup:
You'll notice that I have 3 instances of
ProductController shown here in my view. The 3rd item in the list is the "correct" one, meaning that is the one that is within a project on a Java build path and that Eclipse will pick up as a Java file. We want the other 2 items out of our view. The way to achieve this is to split the projects into 2 working sets: 1 with just the top level project in it, and 1 with the 3 Java projects inside of it.
To configure your working sets:
Now we need to hide the 'Maven Top Level' working set from the 'Open Resource' and 'Open Type' views:
ctrl+shift+ron Windows and Linux or
cmd+shift+ron OSX, then click on the black down-caret on the top right, then click on 'Select Working Set':
Now if you type 'ProductController' in the dialog, you only get a single result!
You might be used to running Eclipse's embedded Tomcat instance available in the "Servers" view. This documentation is coming soon.