Java low-code project overview
At this point it is assumed that the initial setup and the mandatory commands of the Solution CLI have been performed and executed as described.
Prerequisites
Be sure you have set up and installed all prerequisites and development tools.
If you encounter an error related to missing maven dependency de.knowis.cp.sdk:cp-framework-sdk-parent:pom:x.y.z
, then
you have to update the project's pom.xml
file in the Git repository due to updates in the cp-framework. There is only the root level pom.xml file that has to be changed.
First, see upgrade overview to find the current version of the
cp-framework-managed-sdk-parent-x.y.z
Then, inside the project search for the root
pom.xml
, search for the<parent>
attribute and change it according to the following snippet:
<parent>
<groupId>de.knowis.cp.sdk</groupId>
<artifactId>cp-framework-managed-sdk-parent</artifactId>
<version>x.y.z</version>
<relativePath>
./.framework/repo/de/knowis/cp/sdk/cp-framework-managed-sdk-parent/x.y.z/cp-framework-managed-sdk-parent-x.y.z.pom
</relativePath>
</parent>
Create a new project workspace
After you have created a project in Solution Designer and modelled it according to Domain Driven Design principles, create a folder for your workspace. Then, open a terminal and navigate to your development workspace folder.
Example:
cd /my/workspace/
Clone project to local workspace
Inside Solution Designer, open the project and click on Project CLI in the task bar located at the bottom of the page.
There you will find instructions on how to set up the CLI and connect it with your k5-project. The section Implementation provides the necessary information for the fss clone
command to clone the project to your local workspace.
Example:
/my/workspace/SOL
Open project
Open your project folder using Eclipse, IntelliJ or preferred IDE.
Open project with Eclipse
You can use the Import Wizard to command link import Java low-code projects into workspace.
Launch Eclipse.
Open or create a Workspace.
From the main menu bar, select command link File > Import.... The Import wizard opens.
Select General > Projects from Folder or Archive and click Next.
Click the Directory button on the next page of the wizard to select the directory the name of the project acronym.
Under Folder select all projects.
Click Finish to start the import.
The imported project named project acronym-application is the working project it is automatically recognized and created as a Maven project. Alternatively, only the project acronym-application directory can be imported.
Open project with IntelliJ
You can use the Welcome screen to import Java low-code projects.
Launch IntelliJ.
If the Welcome screen opens, click Open.
Otherwise, from the main menu, select File | Open.
In the dialog that opens, select the pom.xml file from the directory with the name of the project acronym-application and click Open.
Alternatively, project acronym can be opened and Maven set up.
Project structure
The project is structured into several source folders and some configuration files inside the ProjectAcronym-application folder:
src/main/java: Holds the project's spring boot entry point and also stub files where solution engineer needs to implement logic for API, services, commands, agents and external entities services
src/main/generated: Holds the generated SDK files for API and domain namespaces
src/test/java: Holds the test files (currently only one test file for database service)
src/main/resources: Holds the resources files such as
application.yaml
andapplication-local-template.yaml
src/test/resources: Holds the resources files for running tests
target: The maven default output folder. When a project is built or packaged, all the content of the sources, resources and web files will be put inside
pom.xml: XML file that contains information about the project and configuration details used by Maven to build the project
Project stubs package structure
Contains Java stub (implementation files) classes where solution engineers can implement logic for modelled operations, services, commands, agents and external entities.
The base package for stubs is named according to package name that is set in the project's Master Data and the project acronym, for example: de.knowis.cnr
It consists of two main sub-packages Api and Domain, where each package groups several namespaces. Api and domain sub-packages correspond to the namespace types that are described in Introduction to Namespaces.
Each namespace will get its own sub-package with its own prefix.
Example:
de.knowis.cnr.api.apins1: corresponds to an API namespace with prefix APIns1
de.knowis.cnr.domain.dns1: corresponds to a domain namespace with prefix dns1
Project local profile configuration setup
To setup your project local profile configuration please see Setup Java local profile.
Project SDK package structure
Contains SDK classes that provide base classes for modelled operations, services, commands, agents and external entities as well as necessary configuration and services needed to run application.
The base package for SDK is named according to the package name that is set in the project's Master Data and the project acronym with addition of "sdk/API" to distinguish it from project stubs, for example: de.knowis.cnr.sdk
It consists of two main sub-packages Api and Domain, where each package groups several namespaces. Api and domain sub-packages correspond to the namespace types that are described in Introduction to Namespaces. Each namespace will get its own sub-package with its own prefix.
Example:
de.knowis.cnr.api.apins1.api: corresponds to an API namespace with prefix APIns1
de.knowis.cnr.sdk.domain.dns1: corresponds to a domain namespace with prefix dns1
Unit tests for low-code projects
It's highly recommended writing unit tests for your Java projects. The unit tests will be executed during the project pipeline execution as part of the maven build.
By default, JUnit 5 is set as the test library in Spring Boot. If you want to use JUnit 4, you have to add the following dependency in pom.xml.
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
</exclusions>
</dependency>