FlexiCore Boot Hello World
A refresher on FlexiCore Boot (version 5.0)
What you’ll need
A Java™ Development Kit (JDK) installed. We recommend AdoptOpenJDK version 11 or 8.
Apache Maven version 3.1 or later installed.
An Integrated Developer Environment (IDE)
Popular choices include IntelliJ IDEA, Spring Tools, Visual Studio Code, or Eclipse, and many others.
Java installed (version 8 or better)
What you'll build
You will build a Spring Boot Application and expand it with two interdependent plugins.
The created application is a standard Spring Boot application.
You can skip the previous part if you want to add plugins support to an existing Spring Boot application.
You can now create the Spring Boot application by running:
from the command line when your current folder is where the pom.xml resides.
Alternatively, you can package from the IDE.
from the command line, change the current directory to the target folder and run
the above is a standard hello world Spring Boot application.
We will now add FlexiCore plugins support using a single annotation.
The only annotation required for supporting inter-dependent plugins is:
You will need to re-compile the Spring Boot application after including the required dependency on FlexiCore Boot and the required annotation.
Once the application is compiled with the above annotation, additional features can be added using
We will build a simple plugin that will do nothing but adding some information to our log file.
Create a new Maven-based project.
Change the pom.xml file to the content below.
Update the HelloWorld class file.
build the plugin by
copy the created jar file into the plugins folder under the folder where the main spring application is located.
Before we run our application we need to make sure that the application.properties file inside the config folder is properly defined.
In case you are adding plugins support to an existing application with an existing application.properties file, add one line to your properties file
Save the file in the config folder and name it :
Save the file in the config folder name it :
Note: The structure of both files allows moving this file structure to any location,.
Now run the Spring boot application:
Form the command line:
You can verify that the plugin was correctly run and deployed by looking into the log folder
You should see a line similar to this:
Note: FlexiCore plugin system for Spring is unique as it allows plugins to provide services to other plugins, this is possible to any depth.
When building a dependent plugin, the injected plugin maven coordinates are needed in the pom.xml file. The injection is done in runtime by FlexiCore, thus the scope entry in the pom.xml is set to ‘provided’. So, the created dependent plugin jar doesn’t include any of the classes defined in the injected plugin.
Create a new Maven project and replace the pom file:
or install from the IDE
copy the provider-1.0.0.jar file into the plugins folder hosting the previous plugin.
if you now run the application you will find that there are two plugins detected:
We will now show how the HelloWorld plugin makes use of the new provider plugin.
Add the maven coordinates of the injected plugins to pom.xml and update few other sections:
Note: The last section is essential, plugins using injected plugins should declare the plugin-dependencies section as a comma-separated list of plugins artifact-id and version. This should be placed inside the manifestEntries section of the maven shade-plugin section of the full pom.xml of the HelloWorld plugin above.
Note the added lines
Now the provider plugin bean is injected to the HelloWorld plugin and its public methods, entities and classes are available from within the HelloWorld plugin.
Obviously, the injected plugin has no ‘knowledge’ of other plugins using its services.
Build the HelloWorld plugin and copy it into the plugins folder.
now run the Spring Boot application again:
Verify by looking at the log file: