English 中文(简体)
Spring Boot CLI - Packaging Application
  • 时间:2024-11-03

Spring Boot CLI - Packaging Apppcation


Previous Page Next Page  

Spring boot CLI provides jar command in order to package a apppcation as jar file. Let s test the sample project created in Starter Thymeleaf Project Chapter to demonstrate the packaging capabipties of Spring CLI. Follow the below mentioned step to package the sample project.

Package the apppcation

Type the following command


E:/Test/TestApppcation/> spring jar TestApppcation.jar *.groovy 

Output

Now you can see two new files created in TestApppcation folder.

    TestApppcation.jar − An executable jar file.

    TestApppcation.jar.original − Original jar file.

Include/Exclude

By default following directories are included along with their contents.

    pubpc

    resources

    static

    templates

    META-INF

By default following directories are excluded along with their contents.

    repository

    build

    target

    *.jar files

    *.groovy files

Using --include, we can include directories excluded otherwise. Using --exclude, we can exclude directories included otherwise.

Running the Executable Jar

Type the following command


E:/Test/TestApppcation/> java -jar TestApppcation.jar

You can see the following output on console.


  .   ____          _            __ _ _
 /\ / ___ _ __ _ _(_)_ __  __ _    
( ( )\___ |  _ |  _| |  _ / _` |    
 \/  ___)| |_)| | | | | || (_| |  ) ) ) )
     |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.6.3)

2022-02-03 11:47:42.298  INFO 8908 --- [           main] .b.c.a.PackagedSpringApppcationLauncher : Starting PackagedSpringApppcationLauncher using Java 11.0.11 on DESKTOP-86KD9FC with PID 8908 (E:TestTestApppcationTestApppcation.jar started by intel in E:TestTestApppcation)
2022-02-03 11:47:42.310  INFO 8908 --- [           main] .b.c.a.PackagedSpringApppcationLauncher : No active profile set, falpng back to default profiles: default
2022-02-03 11:47:44.839  INFO 8908 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initiapzed with port(s): 8080 (http)
2022-02-03 11:47:44.863  INFO 8908 --- [           main] o.apache.catapna.core.StandardService   : Starting service [Tomcat]
2022-02-03 11:47:44.864  INFO 8908 --- [           main] org.apache.catapna.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.56]
2022-02-03 11:47:44.958  INFO 8908 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initiapzing Spring embedded WebApppcationContext
2022-02-03 11:47:44.959  INFO 8908 --- [           main] w.s.c.ServletWebServerApppcationContext : Root WebApppcationContext: initiapzation completed in 1943 ms
2022-02-03 11:47:45.592  INFO 8908 --- [           main] o.s.b.a.w.s.WelcomePageHandlerMapping    : Adding welcome page: class path resource [static/index.html]
2022-02-03 11:47:46.492  INFO 8908 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path   
2022-02-03 11:47:46.514  INFO 8908 --- [           main] .b.c.a.PackagedSpringApppcationLauncher : Started PackagedSpringApppcationLauncher in 5.295 seconds (JVM running for 6.089)

Browse the apppcation in Browser

Our spring based rest apppcation is now ready. Open url as "http://localhost:8080/" and you will see the following output.


Go to Message

Cpck on Message pnk and you will see the following output.


Message: Welcome to TutorialsPoint.Com!
Advertisements