Spring Boot is an extension of the
Spring Framework project, which simplifies the configuration and development of Java applications. It provides a set of predefined standards and default settings to speed up development.
The main difference when using Spring Boot on a
Knowledge Base with the Java
environment is that you don't need to have Tomcat installed to
Build your KB. This is because Spring Boot comes with an embedded Tomcat server.
In addition to this advantage, Spring Boot offers other benefits in GeneXus, such as:
- Accelerated prototyping, which allows creating Java applications quickly and easily.
- Automatic download and configuration of Spring Boot by setting Spring Boot in the Java Framework property and selecting "Rebuild All".
- Unlike Tomcat, which generates a folder structure in the "webapps" directory, Spring Boot generates a single JAR file called "web.jar" in "build\libs", which contains your application ready to run.
Follow the steps below to Build your KB using Spring Boot:
- Make sure you have JDK 17 or higher installed.
- Go to Preferences and check that the current environment is Java.
- Configure the JDK Directory (JAVA HOME) property with the path where the JDK is installed.
- Set the value Spring Boot in the Java Framework property and select "Rebuild All". GeneXus detects that you have selected Spring Boot as the framework and automatically downloads and configures Spring Boot.
If the server is not previously active, GeneXus will start it automatically after compilation or before running the application.
- Press F5 or select Build > Run Developer Menu. Also, it is possible to run from the command line, using:
java.exe -jar web.jar
Note that Spring Boot uses the same default port as Tomcat (port 8080). Therefore, if you decide to use Spring Boot, make sure to disable all Tomcat servers on the machine. This will avoid port conflicts so that the application runs smoothly with Spring Boot.
Applications using Spring Boot framework are always JakartaEE applications.
- Change the server port at runtime.
When packaging and running the Spring Boot application, you can set the server.port argument with the java command:
java -jar web.jar --server.port=8083
or by using the equivalent syntax:
java -jar -Dserver.port=8083 web.jar
Check here for more information.
- Change the context path at runtime.
By default the context path is taken from the application.properties file, for example:
server.servlet.context-path=/TestAzureJavaSQLServer
To change that value, you can use the SERVER_SERVLET_CONTEXT_PATH environment variable or other options available, like setting the property at runtime:
java -jar app.jar --server.servlet.context-path=/mypath
See here for more information.
See Deploying Java applications with Spring Boot