此内容没有您所选择的语言版本。
Chapter 5. Using Thorntail fractions
5.1. Fractions 复制链接链接已复制到粘贴板!
Thorntail is defined by an unbounded set of capabilities. Each piece of functionality is called a fraction. Some fractions provide only access to APIs, such as JAX-RS or CDI; other fractions provide higher-level capabilities, such as integration with RHSSO (Keycloak).
The typical method for consuming Thorntail fractions is through Maven coordinates, which you add to the pom.xml file in your application. The functionality the fraction provides is then packaged with your application (see Section 9.2, “Creating an uberjar”).
To enable easier consumption of Thorntail fractions, a bill of materials (BOM) is available. For more information, see Chapter 6, Using a BOM.
5.2. Auto-detecting fractions 复制链接链接已复制到粘贴板!
Migrating existing legacy applications to benefit from Thorntail is simple when using fraction auto-detection. If you enable the Thorntail Maven plugin in your application, Thorntail detects which APIs you use, and includes the appropriate fractions at build time.
By default, Thorntail only auto-detects if you do not specify any fractions explicitly. This behavior is controlled by the fractionDetectMode property. For more information, see the Maven plugin configuration reference.
For example, consider your pom.xml already specifies the API .jar file for a specification such as JAX-RS:
Thorntail then includes the jaxrs fraction during the build automatically.
Prerequisites
-
An existing Maven-based application with a
pom.xmlfile.
Procedure
Add the
thorntail-maven-pluginto yourpom.xmlin a<plugin>block, with an<execution>specifying thepackagegoal.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Perform a normal Maven build:
mvn package
$ mvn packageCopy to Clipboard Copied! Toggle word wrap Toggle overflow Execute the resulting uberjar:
java -jar ./target/myapp-thorntail.jar
$ java -jar ./target/myapp-thorntail.jarCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Related Information
5.3. Using explicit fractions 复制链接链接已复制到粘贴板!
When writing your application from scratch, ensure it compiles correctly and uses the correct version of APIs by explicitly selecting which fractions are packaged with it.
Prerequisites
-
A Maven-based application with a
pom.xmlfile.
Procedure
-
Add the BOM to your
pom.xml. For more information, see Chapter 6, Using a BOM. -
Add the Thorntail Maven plugin to your
pom.xml. For more information, see Section 9.2, “Creating an uberjar”. Add one or more dependencies on Thorntail fractions to the
pom.xmlfile:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Perform a normal Maven build:
mvn package
$ mvn packageCopy to Clipboard Copied! Toggle word wrap Toggle overflow Execute the resulting uberjar:
java -jar ./target/myapp-thorntail.jar
$ java -jar ./target/myapp-thorntail.jarCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Related Information