Official Content

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. 

Steps to Build your KB with Spring Boot

Follow the steps below to Build your KB using Spring Boot:
  1. Make sure you have JDK 17 or higher installed.
  2. Go to Preferences and check that the current environment is Java.
  3. Configure the JDK Directory (JAVA HOME) property with the path where the JDK is installed.
  4. 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.
  5. 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. 

Considerations

  • Java Platform

    Applications using Spring Boot framework are always JakartaEE applications.
  • Changing 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

    Also, you can do so by using the equivalent syntax:

    java -jar -Dserver.port=8083 web.jar

     See Externalized Configuration for more information.

  • Changing 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 Spring Boot Change Context Path for more information.

Deployment

See Deploying Java applications with Spring Boot

Temporary Limitations

URL Rewrite object is not supported or considered.

Availability

This functionality is available since GeneXus 18 Upgrade 10.

  

Last update: November 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant