This article explains how to build the current ChestnutCMS backend into a WAR package that can be deployed to external Servlet containers.
| Project | Requirements |
|---|---|
| Build directories | The root directory of the repository, which contains the top-level content. pom.xml Table of Contents |
| JDK | JDK 17,java、javac The Maven and Maven tools should use the same JDK. |
| Construction tools | Maven allows access to dependency repositories that are configured for the project. |
| External Web Containers | Jakarta Servlet 6.1 or higher version |
The current code uses Spring Boot 4.0.7 and Spring Framework 7.0.8. The compilation target is Java 17. It cannot be built or run using JDK 8.
Check the actual Java version being used on this machine:
java -version
javac -version
mvn -version
Please make sure to check the key points carefully. mvn -version The Java version and Java home settings. If there are multiple JDKs on this machine, please set them first. JAVA_HOME and PATH Then, proceed with the build process.
The project has been configured for deployment on external containers. There is no need to manually modify the packaging method or add additional components. web.xml:
chestnut-admin/pom.xml Default generation of JAR files; enabled war After creating the profile,chestnut.admin.packaging Become war。spring-boot-starter-tomcat and jakarta.servlet-api Declare as in the WAR profile provided。ChestnutServletInitializer Inherit SpringBootServletInitializer Initialized by an external container. ChestnutApplication。maven-war-plugin Allow projects to not provide web.xml。repackage The final product name is fixed as chestnut-admin.war。The executable WAR file for Spring Boot may contain WEB-INF/lib-provided/ This is the normal packaging result. This directory is used to store the dependencies that are provided; when deploying to BES, these JAR files do not need to be manually transferred there. WEB-INF/lib/ Or BES-related lib/ Down.
Execute in the root directory of the repository:
mvn -Pwar,media-linux64 -pl chestnut-admin -am clean package -Dmaven.test.skip=true
Parameter meanings:
| Parameters | Functionality |
|---|---|
-Pwar | Enable the WAR packaging configuration used by external Servlet containers |
-Pmedia-linux64 | Select the JAVE media processing native component for Linux x86_64 |
-pl chestnut-admin | Select the backend entry module only. |
-am | Build other project modules that rely on this entry point simultaneously. |
clean package | Clean up old build artifacts and repackage them. |
-Dmaven.test.skip=true | Skip testing, compilation, and execution. Suitable for deliveries that have already undergone testing. |
Multiple profiles can be written in the same place. -P Parameters are set. The above command can also be written as -Pwar -Pmedia-linux64。
If you need to compile the test code but do not want to execute the tests, then… -Dmaven.test.skip=true Change to -DskipTests When testing is required, remove the skipped parameters and prepare the environment necessary for the test to proceed.
It only verifies the commands used when the application is launched, or when it’s necessary to retain the default multi-platform media components.
mvn -Pwar -pl chestnut-admin -am package -Dmaven.test.skip=true
chestnut-cms-media that media-all The “profile” option is enabled by default and includes media components for Linux, Windows, and macOS. If you explicitly select a single-platform profile for this module, the default profile will be disabled.
| Deployment objectives | Media Profile |
|---|---|
| Linux x86_64 | media-linux64 |
| Windows x86_64 | media-win64 |
| macOS Apple Silicon | media-osxm1 |
| macOS Intel | media-osx64 |
It is necessary to select the deployment server, rather than the build machine. For other CPU architectures, matching media processing components need to be prepared separately.
The build log should be displayed. BUILD SUCCESS The product is located at:
chestnut-admin/target/chestnut-admin.war
Do not include files that are in the same directory as these files. .original The file is considered to be the final delivery package.
Check whether there is an entry class in the WAR file:
jar tf chestnut-admin/target/chestnut-admin.war | grep 'WEB-INF/classes/com/chestnut/ChestnutServletInitializer.class'
Checklist and compilation versions of various items:
unzip -p chestnut-admin/target/chestnut-admin.war META-INF/MANIFEST.MF
javap -verbose -classpath chestnut-admin/target/classes com.chestnut.ChestnutApplication | grep 'major version'
The list should include the current Spring Boot version and Start-Class: com.chestnut.ChestnutApplication The major version of the Java 17 project class should be 61。
Check the file verification values before and after transmission. For Linux systems:
sha256sum chestnut-admin/target/chestnut-admin.war
Usage on macOS:
shasum -a 256 chestnut-admin/target/chestnut-admin.war
WAR will be included in the results. application.yml This can be configured according to individual profiles. However, it is recommended to store the server’s database, Redis settings, directories, and log configurations in external files.
WAR only includes the backend components; it does not include any other elements. chestnut-ui-vue3 The backend management page after construction. Access /login/config Obtaining a valid JSON response indicates that the backend interface is functional. The backend pages require a separate front-end construction, with static resources provided by Nginx.
| phenomena | Check method |
|---|---|
Only the final version is available. .jar | Confirmed to be enabled war Profile. The directory being checked is chestnut-admin/target |
| No other Chestnut modules found as dependencies. | Executed from the root directory of the repository, and remains intact. -am |
release version 17 not supported | Inspection mvn -version Maven may still be using the old JDK. |
| After container deployment, there is no Spring context, or the interface always returns a 404 error. | Confirm that the container supports Jakarta Servlet 6.1, check the entry class and complete startup logs. |
Unsupported class file major version 68/69 | First, determine the specific JAR files and class paths. 68 corresponds to Java 24, 69 corresponds to Java 25. It may also come from dependencies. META-INF/versions/ For multi-version classes, it cannot be concluded that the project was compiled using the corresponding JDK directly. |
| The audio and video processing is not available. | Check whether the media profile matches the target operating system and CPU, and verify the media processing capabilities separately. |